Pages

Determine character is letter or digit

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

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


public class DetermineCharacterIsLetterOrDigit
{
public static void main(String[]args)
{
//Create a character using char with value(3)
//You can try change it's value to letter(k)
char a='3';

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


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