Java Character isSpaceChar() Method

The isSpaceChar(char ch) method of Character class determines whether the given(or specified) character is a Unicode space character.

The given(or specified) character is considered to be a space character if the character is specified as a space character by the Unicode Standard.

The above method returns true if the general category of the character is one of the following:

  • SPACE_SEPARATOR
  • LINE_SEPARATOR
  • PARAGRAPH_SEPARATOR

Syntax

Parameter

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

Return Value

The isSpaceChar(char ch) method returns a Boolean value, i.e., true if the given(or specified) character is a space character. 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 second character is a space character: true

Example 2

Output:

The first character is a space character: false
The first character is a space character: false

Example 3

Output:

Enter the first input:_
The character '_' is not a space character.
Enter the second input:}
The character '}' is a space character.
Enter the third input:*
The character '*' is not a space character.