Online Java Compiler By
JavaTpoint.com
import java.lang.*; public class Enum_hashCodeMethodExample3 { public static void main(String[] args) { int red1=colours.red.hashCode(); System.out.println("hash code of red ="+red1); int Red1=colours.Red.hashCode(); System.out.println("hash code of Red ="+Red1); int REd1=colours.REd.hashCode(); System.out.println("hash code of REd ="+REd1); int RED1=colours.RED.hashCode(); System.out.println("hash code of RED ="+RED1); System.out.println(); if(Integer.compare(Red1,red1)>0&&Integer.compare(red1,REd1)>0&&Integer.compare(red1,RED1)>0){ System.out.println(red1+" is greater."); } else if(Integer.compare(Red1,RED1)>0&&Integer.compare(red1,RED1)>0){ System.out.println(Red1+" is greater"); } else if(Integer.compare(REd1,RED1)>0){ System.out.println(REd1+"is greater."); } else{ System.out.println("Hash code "+RED1+" is greater."); } } enum colours{ red,Red,REd,RED; } }
Output