Online Java Compiler By
JavaTpoint.com
import java.util.*; public class EnumMapHashCodeExample1 { // create an enum public enum Tutorial{ CSS, Python, PHP, Java, Javascript }; public static void main(String[] args) { //create and populate enum EnumMap
map = new EnumMap
(Tutorial.class); map.put(Tutorial.CSS, "1"); map.put(Tutorial.Python, "2"); map.put(Tutorial.PHP,"3"); map.put(Tutorial.Java, "4"); //print the hash code value of the map System.out.println("Hash code value of the map: "+map.hashCode()); //clear the map map.clear(); // print the hash code value of the map again System.out.println("Hash code value after clearing the map: "+map.hashCode()); } }
Output