1public class JavaCharacterCompareExample1 {
2public static void main(String[] args) {
3char firstValue = 'A';
4char secondValue = 'B';
5// compare the first char to the second
6 int compareOneTwo = Character.compare(firstValue, secondValue);
7 if (compareOneTwo> 0) {
8 System.out.println("First value is greater than second value");
9 }
10 else {
11System.err.println("First value is less than second value.");
12 }
13 }
14}
15
16// OUT: First value is less than the second value.
17
1If your input is a character and the characters you are checking against are mostly consecutive you could try this:
2
3if ((symbol >= 'A' && symbol <= 'Z') || symbol == '?') {
4 // ...
5}
6