Online Java Compiler By
JavaTpoint.com
public class Enum_hashCodeMethodExample1 { enum Seasons{ winter,summer,spring,rainy,autumn; } public static void main(String[] args) { for(Seasons seasons : Seasons.values()){ //it will print the hashCode of all the enum constants int a =seasons.hashCode(); System.out.println("Hash code for "+seasons+" = " +a); } } }
Output