Online Java Compiler By
JavaTpoint.com
public class Enum_compareToMethodExample3{ enumColour{ red,Red; } public static void main(String[] args) { Colour red, Red; red = Colour.red; Red = Colour.Red; //Upper case has higher value than lower case. int val = red.compareTo(Red); if( val>0){ System.out.println("red is greater than Red."); } else if(val<0){ System.out.println("Red is greater than red."); } else{ System.out.println("red and Red both are equal ."); } } }
Output