Online Java Compiler By
JavaTpoint.com
public class JavaCharacterCompareExample2{ public static void main(String[] args) { char firstValue = '1'; char secondValue = '2'; // compare the first char to the second int comp = Character.compare(firstValue, secondValue); if (comp< 0) { System.err.println("Value 1 is greater than the value 2."); } else { System.err.println("Value 1 is less than the second value2."); } } }
Output