Java – EnumMap Class

Java EnumMap Class methods, constructors, variables available in Java 8 release are listed below. We will publish example program on each methods ASAP.

Constructors in Java EnumMap Class

S.No Constructor & Description
1 EnumMap(Class<K> keyType)

Creates an empty enum map with the specified key type.
2 EnumMap(EnumMap<K,? extends V> m)

Creates an enum map with the same key type as the specified enum map, initially containing the same mappings (if any).
3 EnumMap(Map<K,? extends V> m)

Creates an enum map initialized from the specified map.

Methods in Java EnumMap Class

S.No Method & Description
1 void clear()

Removes all mappings from this map.
2 EnumMap<K,V> clone()

Returns a shallow copy of this enum map.
3 boolean containsKey(Object key)

Returns true if this map contains a mapping for the specified key.
4 boolean containsValue(Object value)

Returns true if this map maps one or more keys to the specified value.
5 Set<Map.Entry<K,V>> entrySet()

Returns a Set view of the mappings contained in this map.
6 boolean equals(Object o)

Compares the specified object with this map for equality.
7 V get(Object key)

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
8 int hashCode()

Returns the hash code value for this map.
9 Set<K> keySet()

Returns a Set view of the keys contained in this map.
10 V put(K key, V value)

Associates the specified value with the specified key in this map.
11 void putAll(Map<? extends K,? extends V> m)

Copies all of the mappings from the specified map to this map.
12 V remove(Object key)

Removes the mapping for this key from this map if present.
13 int size()

Returns the number of key-value mappings in this map.
14 Collection<V> values()

Returns a Collection view of the values contained in this map.

Ask your questions in eHowToNow Forum

Post your technical, non-technical doubts, questions in our site. Get answer as soon as possible, meanwhile you can help others by answering, unanswered questions.
To Ask new Question : Ask Question
Check our existing discussions : Questions & Answers

  1. Java – Objects Class in Util Package
  2. Java – SplittableRandom Class
  3. Java – ConcurrentNavigableMap Interface
  4. Java – BiFunction Interface
  5. Java – IntBinaryOperator Interface
  6. Java – Observable Class
  7. Java – StringJoiner Class
  8. Java – ConcurrentHashMap.KeySetView Class
  9. Java – DoubleBinaryOperator Interface
  10. Java – List Interface
  11. Java – ObjIntConsumer Interface
  12. Java – IntSupplier Interface
  13. Java – IntPredicate Interface
  14. Java – DoublePredicate Interface
  15. Java – GregorianCalendar Class

Be the first to comment

Leave a Reply