Java Character isSpace() Method

The isSpace(char ch)method of Character class determines whether the given(or specified) character is ISO-LATIN-1 white space.

The given method returns true for the following five characters:

  • '\t'     U+0009     HORIZONTAL TABULATION
  • '\n'     U+000A     NEW LINE
  • '\f'     U+000C     FORM FEED
  • '\r'     U+000D     CARRIAGE RETURN
  • ' '     U+0020     SPACE

Syntax

Parameters

ch: It is the character that needs to be tested.

Return Value

The isSpace(char ch)method returns a Boolean value, i.e., true if the given(or specified) character is ISO-LATIN-1 white space. Otherwise, the method returns false.

Example 1

Output:

The first character is a space character: true
The second character is a space character: true
The third character is a space character: true

Example 2

Output:

The first character is a space character: true
The second character is a space character: true