Home Tutorial Java Corejava Check for character having white space or not

 
 

Check for character having white space or not
Posted on: June 29, 2010 at 12:00 AM
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

Related Tags for Check for character having white space or not:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.