Check for character having white space or not


 

Check for character having white space or not

This example help you find whether the char variable's value is having white space or not

This example help you find whether the char variable's value is having white space or not

Description:

This tutorial demonstrate how to check white space present in the char variable's value using isWhitespace() method.

Code:

public class IsWhiteSpace {
  public static void main(String[] args) {
    char value = ' ';
    if (Character.isWhitespace(value)) {
      System.out.println("true");
    else {
      System.out.println("false");
    }
  }
}

Output:

Download this code

Ads