Share on Google+Share on Google+

Check for character is letter or digit.

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

Advertisements

Advertisement

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

Share this Tutorial 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.