Two characters can be compared using the relational operators.
This is done by comparing the Unicode of the two characters.
For example,
For example, the following code tests whether a character ch is an uppercase letter, a lowercase letter, or a digital character.
public class Main { public static void main(String[] argv) throws Exception { char ch = 'C'; if (ch >= 'A' && ch <= 'Z') System.out.println(ch + " is an uppercase letter"); else if (ch >= 'a' && ch <= 'z') System.out.println(ch + " is a lowercase letter"); else if (ch >= '0' && ch <= '9') System.out.println(ch + " is a numeric character"); }/*from ww w .j a va 2s .c o m*/ }