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

 
 

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

Advertisement

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


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 29, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com