isSpaceChar()
is a static method of the Character
class in Java used to determine whether a given character is a Unicode space character.
A space character is only regarded as a space character if the Unicode Standard specifies it as a space character. If the character’s general category type is any of the following, the function returns true
:
public static boolean isSpaceChar(char ch)
char ch
: the character to be checked
isSpaceChar()
returns true
if the character is a Unicode space character. Otherwise, it returns false
.
public static boolean isSpaceChar(int codePoint)
public static boolean isSpaceChar(char ch)
In the code below, we pass different Unicode characters to the method to check for the space character:
public class Main { public static void main(String[] args){ System.out.println(Character.isSpaceChar(' ')); System.out.println(Character.isSpaceChar('\u2029')); System.out.println(Character.isSpaceChar('\u2028')); System.out.println(Character.isSpaceChar('\u2056')); } }
RELATED TAGS
CONTRIBUTOR
View all Courses