Share on Google+Share on Google+

Check for character having white space or not

Ads
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

Advertisements

Posted on: June 29, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial 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.

Ads

Advertisement