compare string java cahr to char code example
Example: how to compare a char to a string java
public class JavaCharacterCompareExample1 {
public static void main(String[] args) {
char firstValue = 'A';
char secondValue = 'B';
// compare the first char to the second
int result = Character.compare(firstValue, secondValue);
if (result == 0) {
System.out.println("The chars are the same.");
} else {
System.out.println("The chars are different.");
}
}
}