Determining the Type of a Character - Java Language Basics

Java examples for Language Basics:char

Description

Determining the Type of a Character

Demo Code


public class Main {
  public void m() throws Exception {
    char ch = 'a';
    if (Character.isLetter(ch)) { // true
    }//  ww w. jav  a 2 s .co  m
    if (Character.isDigit(ch)) { // false
    }
    if (Character.isLowerCase(ch)) { // true
    }
    if (Character.isUpperCase(ch)) { // false
    }
    // See Character for more methods.
  }
}

Related Tutorials