Pages

Determine character is whitespace

Complete source code below will show you, how to determine character is whitespace or not in java.

*******************************************************************
COMPLETE SOURCE CODE FOR : DetermineCharacterIsSpace.java
*******************************************************************


public class DetermineCharacterIsSpace
{
public static void main(String[]args)
{
//Create a space character using char by press spacebar once between single quote(' ')
//You can try change it's value by change it to a letter 'A' for example.
char a=' ';

//Determine created character is space or not
//using method isWhitespace from class Character.
//isWhitespace is a static method, so we don't need to create object when
//we want to use it.
if(Character.isWhitespace(a))
{
//Print (It is a whitespace) if character is a whitespace
System.out.println("It is a whitespace");
}
else
{
//Print (It is not a whitespace) if character is not a whitespace
System.out.println("It is not a whitespace");
}
}
}


*******************************************************************
JUST COMPILE AND EXECUTE IT
*******************************************************************
Related Posts Plugin for WordPress, Blogger...