Both of them returns true if it is empty char / white space or else it returns false. My question is why java has both the methods as they are doing the same thing
Method isSpaceChar(char)
is only for checking unicode space character (SPACE_SEPARATOR,LINE_SEPARATOR, PARAGRAPH_SEPARATOR) while method isWhiteSpace(char)
is for space as well as other white space characters like tab,carriage return etc
char ch='\t';
System.out.println(Character.isWhitespace(ch));
System.out.println( Character.isSpaceChar(ch));
It outputs
true
false
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With