Online Java Compiler By
JavaTpoint.com
public class JavaCharacterCompareExample1 { public static void main(String[] args) { char firstValue = 'A'; char secondValue = 'B'; // compare the first char to the second int compareOneTwo = Character.compare(firstValue, secondValue); if (compareOneTwo> 0) { System.out.println("First value is greater than second value"); } else { System.err.println("First value is less than second value."); } } }
Output