Check for character is letter or digit.

This example checks for character variable value is letter or digit.

 
 

Share on Google+Share on Google+

Check for character is letter or digit.

Ads

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

Advertisements

Posted on: June 29, 2010 If you enjoyed this post then why not add us on Google+? Add us to your Circles