Online Java Compiler By
JavaTpoint.com
import java.util.*; public class EnumMapSizeExample1 { // create an enum public enum Tutorial { Java, CSS, Python, Android, Javascript }; public static void main(String[] args) { EnumMap
map = new EnumMap
(Tutorial.class); map.put(Tutorial.Java, "1"); map.put(Tutorial.CSS, "2"); map.put(Tutorial.Python, "3"); map.put(Tutorial.Android, "4"); //print the map System.out.println("Map: "+map); //print the number of mapping of this map System.out.println("Number of mappings: "+map.size()); //put one Key-value in this map map.put(Tutorial.Javascript, "5"); //print the map System.out.println("Map: "+map); //print the new number of mappings of this map System.out.println("Number of mappings: "+map.size()); } }
Output