Home Tutorial Java Corejava Check for character is letter or digit.

 
 

Check for character is letter or digit.
Posted on: June 29, 2010 at 12:00 AM
This example checks for character variable value is letter or digit.
Description

Description:

This tutorial demonstrate how to check a character variable value is a digit or letter using isLetterOrDigit() method.

Code:

public class LetterOrDigit {
  public static void main(String[] args) {
    char symbol = '1';
    if (Character.isLetterOrDigit(symbol)) {
      System.out.println("true");
    else {
      System.out.println("false");
    }
    char symbol1 = 'A';
    if (Character.isLetterOrDigit(symbol1)) {
      System.out.println("true");
    else {
      System.out.println("false");
    }
  }
}

Output:

Download this code

Related Tags for Check for character is letter or digit.:


Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.