Example For isWhitespace() method in Java

Example For isWhitespace() method in Java


Posted in : Core Java Posted on : October 1, 2010 at 3:18 PM Comments : [ 0 ]

In this tutorial, We will discuss about the isWhitespace() method of character class in java.

Example For isWhitespace() method in Java

In this tutorial, We will discuss about the isWhitespace() method of character class in java. This method specifies that the given character is white space character or not. The isWhitespace() method returns true if the character is white space character otherwise returns false.

Example: CharacterIsWhiteSpace.java

package com.devmanuals;

public class CharacterIsWhiteSpace {

	public static void main(String[] args) {
		System.out.print("Is character is WhiteSpace= ");
		System.out.println(Character.isWhitespace(' '));
		System.out.print("Is character is WhiteSpace= ");
		System.out.println(Character.isWhitespace('W'));
		System.out.print("Is character is WhiteSpace= ");
		System.out.println(Character.isWhitespace('\n'));
		System.out.print("Is character is WhiteSpace= ");
		System.out.println(Character.isWhitespace('\t'));
		System.out.print("Is character is WhiteSpace= ");
		System.out.println(Character.isWhitespace('\b'));

	}

}

Output:

 Is character  ' ' is WhiteSpace= true

Is character 'W ' is WhiteSpace= false

Is character  '\n' is WhiteSpace= true

Is character '\t'  is WhiteSpace= true

Is character '\b '  is WhiteSpace= false

Download This Example.

Go to Topic «PreviousHomeNext»

Your Comment:


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

 
Tutorial Topics