Latest web development tutorials

Java isWhitespace () method

Java Character class Java Character class


isWhitespace () method is used to determine the specified character is a blank character, contains whitespace: space, tab key, and line breaks.

grammar

boolean isWhitespace(char ch)

parameter

  • ch - the character to be tested.

return value

If the character is a blank character, returns true; otherwise false.

Examples

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 above program execution results:

false
true
true
true

Java Character class Java Character class