Online Java Compiler By
JavaTpoint.com
public class JavaCharacterCompareToExample2 { public static void main(String[] args) { Character first = new Character('T'); Character second = new Character('G'); // compare the first character to the second character. intcompare= first.compareTo(second); if (compare == 0) { System.out.println("The first value 'T' and the second value 'G' are equal."); } else if (compare>0) { System.out.println("The first value 't' is greater than the second value 'G'."); } else { System.out.println("The first value 'T-' is less than the second value'G'."); } } }
Output