Java java.util HashMap fields, constructors, methods, implement or subclass

Example usage for Java java.util HashMap fields, constructors, methods, implement or subclass

Introduction

In this page you can find the methods, fields and constructors for java.util HashMap.

The text is from its open source code.

Subclass

java.util.HashMap has subclasses.
Click this link to see all its subclasses.

Field

SetentrySet
Holds cached entrySet().
intsize
The number of key-value mappings contained in this map.

Constructor

HashMap()
Constructs an empty HashMap with the default initial capacity (16) and the default load factor (0.75).
HashMap(int initialCapacity, float loadFactor)
Constructs an empty HashMap with the specified initial capacity and load factor.
HashMap(int initialCapacity)
Constructs an empty HashMap with the specified initial capacity and the default load factor (0.75).
HashMap(Map m)
Constructs a new HashMap with the same mappings as the specified Map .

Method

voidclear()
Removes all of the mappings from this map.
Objectclone()
Returns a shallow copy of this HashMap instance: the keys and values themselves are not cloned.
Vcompute(K key, BiFunction remappingFunction)

This method will, on a best-effort basis, throw a ConcurrentModificationException if it is detected that the remapping function modifies this map during computation.

VcomputeIfAbsent(K key, Function mappingFunction)

This method will, on a best-effort basis, throw a ConcurrentModificationException if it is detected that the mapping function modifies this map during computation.

booleancontainsKey(Object key)
Returns true if this map contains a mapping for the specified key.
booleancontainsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
booleanequals(Object o)
Compares the specified object with this map for equality.
voidforEach(BiConsumer action)
Vget(Object key)
Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.
ClassgetClass()
Returns the runtime class of this Object .
VgetOrDefault(Object key, V defaultValue)
inthashCode()
Returns the hash code value for this map.
booleanisEmpty()
Returns true if this map contains no key-value mappings.
SetkeySet()
Returns a Set view of the keys contained in this map.
Vmerge(K key, V value, BiFunction remappingFunction)

This method will, on a best-effort basis, throw a ConcurrentModificationException if it is detected that the remapping function modifies this map during computation.

Vput(K key, V value)
Associates the specified value with the specified key in this map.
voidputAll(Map m)
Copies all of the mappings from the specified map to this map.
VputIfAbsent(K key, V value)
Vremove(Object key)
Removes the mapping for the specified key from this map if present.
Vreplace(K key, V value)
booleanreplace(K key, V oldValue, V newValue)
StringtoString()
Returns a string representation of the object.
Collectionvalues()
Returns a Collection view of the values contained in this map.