The Maps.newEnumMap() method is a utility method provided by the Google Guava library in Java, which returns a new instance of the specified enum map. This method can be used to create an enum map that is backed by a HashMap instance.
Example 1: Creating an enum map for days of the week using Maps.newEnumMap() method
Example 2: Creating an empty enum map for colors using Maps.newEnumMap() method
EnumMap colors = Maps.newEnumMap(Color.class);
colors.put(Color.RED, "Red");
colors.put(Color.GREEN, "Green");
colors.put(Color.BLUE, "Blue");
Here, we have used the Maps class of the com.google.common.collect package library to create a new enum map.
Java Maps.newEnumMap - 29 examples found. These are the top rated real world Java examples of com.google.common.collect.Maps.newEnumMap extracted from open source projects. You can rate examples to help us improve the quality of examples.