Pages

Determine character is digit or not

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

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


public class DetermineCharacterIsDigit
{
public static void main(String[]args)
{
//Create a character using char with value(4)
char a='4';

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


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