Skip to content
Java

HashMap API Reference

Java HashMap — hash-table-based implementation of the Map interface.

By EZ4Code Team

HashMap<K,V>

Hash-table-based implementation of the Map interface. Permits null keys and values.

V put(K key, V value)

Associate value with key. Returns the previous value (or null).

Returns: V

V get(Object key)

Return the value to which key is mapped, or null if not present.

Returns: V

V remove(Object key)

Remove the mapping for key. Returns the previous value (or null).

Returns: V

boolean containsKey(Object key)

Return true if the map contains a mapping for the specified key.

Returns: boolean

boolean containsValue(Object value)

Return true if the map maps one or more keys to the specified value.

Returns: boolean

Set<K> keySet()

Return a Set view of the keys contained in the map.

Returns: Set<K>

Collection<V> values()

Return a Collection view of the values contained in the map.

Returns: Collection<V>

Set<Map.Entry<K,V>> entrySet()

Return a Set view of the mappings contained in the map.

Returns: Set<Map.Entry<K,V>>

int size()

Return the number of key-value mappings in the map.

Returns: int

boolean isEmpty()

Return true if the map contains no key-value mappings.

Returns: boolean

More Java API References