Java isWhitespace() Method

Java  Character类Java Character Class


The isWhitespace() method is used to determine whether the specified character is a whitespace character. Whitespace characters include: space, tab key, and line break.

Syntax

boolean isWhitespace(char ch)

Parameters

  • ch-- The character to be tested.

Return Value

Returns true if the character is a whitespace character; otherwise returns false.

Example

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 output of the above program is:

false
true
true
true

Java  Character类Java Character Class

Other Extensions