Methods Declared in Interface ĭescriptionenter compute(K key, BiFunction remappingFunction) Attempts to compute a mapping for the specified key and its current mapped value (or null if there is no current mapping). toString() Returns a string representation of this map. Methods Declared in AbstractMap Classĭescription isEmpty() Returns true if this map contains no key-value mappings. values() Returns a Collection view of the values contained in this map.
size() Returns the number of key-value mappings in this map. remove(Object key) Removes the mapping for this key from this map if present. putAll(Map m) Copies all of the mappings from the specified map to this map. put(K key, V value) Associates the specified value with the specified key in this map. keySet() Returns a Set view of the keys contained in this map.
Java map code#
hashCode() Returns the hash code value for this map. get(Object key) Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key. equals(Object o) Compares the specified object with this map for equality.
entrySet() Returns a Set view of the mappings contained in this map.
containsValue(Object value) Returns true if this map maps one or more keys to the specified value. containsKey(Object key) Returns true if this map contains a mapping for the specified key. clone() Returns a shallow copy of this enum map. Map m = Collections.synchronizedMap(new EnumMap(.)) Methods of EnumMapĪction Performed clear() Removes all mappings from this map. This is best done at the creation time, to prevent accidental unsynchronized access. This is typically accomplished by using the synchronizedMap() method of the Collections class. This means that if multiple threads access a tree set concurrently, and at least one of the threads modifies the set, it must be synchronized externally. The implementation of an EnumMap is not synchronized. Output EnumMap colors Synchronized EnumMap This representation is extremely compact and efficient.