Java Enum compareTo() MethodThe compareTo() method of Enum class compares this enum object with the defined object for order. Enum constants can only be compared to other enum constants of the same type. SyntaxParameterso - It is the enum object that is compared Return ValueThe compareTo() method returns:
Example 1Output: A2 is greater than A1. Example 2Output: Val1= 2 Val2= 1 Val3= 1 Spring is my Fav season amongst all seasons. Example 3Output: Red is greater than red. Next TopicJava-enum-equals-method |
We provides tutorials and interview questions of all technology like java tutorial, android, java frameworks
G-13, 2nd Floor, Sec-3, Noida, UP, 201301, India