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

 
 

Share on Google+Share on Google+
Check for character is letter or digit.
Posted on: June 29, 2010 at 12:00 AM
Advertisement
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

Advertisement

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


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: June 29, 2010

Recommend the tutorial

Advertisements Advertisements
 

 

 

DMCA.com