- Java.util - WeakHashMap
- Java.util - Vector
- Java.util - UUID
- Java.util - TreeSet
- Java.util - TreeMap
- Java.util - TimeZone
- Java.util - TimerTask
- Java.util - Timer
- Java.util - StringTokenizer
- Java.util - Stack
- Java.util - SimpleTimeZone
- Java.util - ServiceLoader
- Java.util - Scanner
- Java.util - ResourceBundle.Control
- Java.util - ResourceBundle
- Java.util - Random
- Java.util - PropertyResourceBundle
- Java.util - PropertyPermission
- Java.util - Properties
- Java.util - PriorityQueue
- Java.util - Observable
- Java.util - Locale
- Java.util - ListResourceBundle
- Java.util - LinkedList
- Java.util - LinkedHashSet
- Java.util - LinkedHashMap
- Java.util - IdentityHashMap
- Java.util - Hashtable
- Java.util - HashSet
- Java.util - HashMap
- Java.util - GregorianCalendar
- Java.util - Formatter
- Java.util - EnumSet
- Java.util - EnumMap
- Java.util - Dictionary
- Java.util - Date
- Java.util - Currency
- Java.util - Collections
- Java.util - Calendar
- Java.util - BitSet
- Java.util - Arrays
- Java.util - ArrayList
- Java.util - ArrayDeque
- Java.util - Home
Java.util Package Extras
- Java.util - Discussion
- Java.util - Useful Resources
- Java.util - Enumerations
- Java.util - Exceptions
- Java.util - Interfaces
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
Java.util.EnumMap Class
Introduction
The java.util.EnumMap class is a speciapzed Map implementation for use with enum keys.Following are the important points about EnumMap −
All of the keys in an enum map must come from a single enum type that is specified, exppcitly or imppcitly, when the map is created.
Enum maps are maintained in the natural order of their keys.
EnumMap is not synchronized.If multiple threads access an enum map concurrently, and at least one of the threads modifies the map, it should be synchronized externally.
Class declaration
Following is the declaration for java.util.EnumMap class −
pubpc class EnumMap<K extends Enum<K>,V> extends AbstractMap<K,V> implements Seriapzable, Cloneable
Class constructors
Sr.No. | Constructor & Description |
---|---|
1 | EnumMap(Class<K> keyType) This constructor creates an empty enum map with the specified key type. |
2 | EnumMap(EnumMap<K,? extends V> m) This constructor 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) This constructor creates an enum map initiapzed from the specified map. |
Class methods
Sr.No. | Method & Description |
---|---|
1 | This method removes all mappings from this map. |
2 | This method returns a shallow copy of this enum map. |
3 | This method returns true if this map contains a mapping for the specified key. |
4 | This method returns true if this map maps one or more keys to the specified value. |
5 | This method returns a Set view of the mappings contained in this map. |
6 | This method compares the specified object with this map for equapty. |
7 | This method returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. |
8 | This method returns a Set view of the keys contained in this map. |
9 | This method associates the specified value with the specified key in this map. |
10 | This method Copies all of the mappings from the specified map to this map. |
11 | This method removes the mapping for this key from this map if present. |
12 | This method returns the number of key-value mappings in this map. |
13 | This method returns a Collection view of the values contained in this map. |
Methods inherited
This class inherits methods from the following classes −
java.util.AbstractMap
java.util.Object