Java isWhitespace() method
isWhitespace() method is used to determine whether the specified character is a whitespace character. The whitespace character includes: space, tab key, and newline character.
grammar
boolean isWhitespace(char ch)
parameter
ch -- The character to test.
return value
Returns true if the character is a whitespace character; otherwise returns false.
Example
public class Test { public static void main(String args[]) { System.out.println(Character.isWhitespace('c')); System.out.println(Character.isWhitespace(' ')); System.out.println(Character.isWhitespace('\n')); System.out.println(Character.isWhitespace('\t')); } }
The execution result of the above program is:
false true true true