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