Easy Tutorial
❮ Net Webpage Dir Traverse ❯

Java isWhitespace() Method

Java Character Class


The isWhitespace() method is used to determine if the specified character is a whitespace character, which includes: space, tab key, and newline character.

Syntax

boolean isWhitespace(char ch)

Parameters

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

false
true
true
true

Java Character Class

❮ Net Webpage Dir Traverse ❯