C:\JDK\jdk\build\windows-x64\images\docs\api\java.base\java\util\HashMap.html
noscript
div
JavaScript is disabled on your browser.
header
nav
div[fixedNav]
div
This specification is not final and is subject to change. Use is ...div[topNav]
- a[#navbar.top]
div[skipNav]
Skip navigation links- a[#navbar.top.firstrow]
ul[navList]
li
Overviewli
Moduleli
Packageli[navBarCell1Rev]
Classli
Useli
Treeli
Deprecatedli
Indexli
Help
div[aboutLanguage]
div
Java SE 13 & JDK 13DRAFT 13-internal+0-2019-04-09-0725291.pri ...
div[subNav]
div
ul[subNavList]
li
Summary: li
Nested | li
Field | li
Constr | li
Method
ul[subNavList]
li
Detail: li
Field | li
Constr | li
Method
div[navListSearch]
SEARCH:
- input[#search]
- input[#reset]
- a[#skip.navbar.top]
div[navPadding]
main
div[header]
div[subTitle]
Module java.basediv[subTitle]
Package java.utilh1[title]
Class HashMap<K,​V>
div[contentContainer]
div[inheritance]
java.lang.Object
div[inheritance]
java.util.AbstractMap<K,​V>
div[inheritance]
java.util.HashMap<K,​V>
section[description]
dl
dt
Type Parameters:dd
K- the type of keys maintained by this mapdd
V- the type of mapped values
dl
dt
All Implemented Interfaces:dd
Serializable,Cloneable,Map<K,​V>
dl
dt
Direct Known Subclasses:dd
LinkedHashMap,PrinterStateReasons
public classHashMap<K,​V>extendsAbstractMap<K,R ...div[block]
Hash table based implementation of theMapinterface. Thisimplement ...dl
dt
Since:dd
1.2dt
See Also:dd
Object.hashCode(),Collection,Map,TreeMap,Hashtable,Serialized For ...
section[summary]
ul[blockList]
li[blockList]
section[nestedClassSummary]
- a[#nested.class.summary]
h2
Nested Class Summarydiv[inheritedList]
h2
Nested classes/interfaces declared in class java.util.Abstra ...- a[#nested.classes.inherited.from.class.java.util.AbstractMap] AbstractMap.SimpleEntry<K,​V>,AbstractMap.SimpleImmut ...
div[inheritedList]
h2
Nested classes/interfaces declared in interface java.util.Ma ...- a[#nested.classes.inherited.from.class.java.util.Map] Map.Entry<K,​V>
li[blockList]
section[constructorSummary]
- a[#constructor.summary]
h2
Constructor Summarydiv[memberSummary]
table
caption
Constructors thead
tr
th[colFirst]
Constructorth[colLast]
Description
tbody
tr[altColor]
th[colConstructorName]
HashMap()td[colLast]
div[block]
Constructs an emptyHashMapwith the default initial capacity(16) a ...
tr[rowColor]
th[colConstructorName]
HashMap​(int initialCapacity)td[colLast]
div[block]
Constructs an emptyHashMapwith the specified initialcapacity and ...
tr[altColor]
th[colConstructorName]
HashMap​(int initialCapacity,float loadFactor)td[colLast]
div[block]
Constructs an emptyHashMapwith the specified initialcapacity and ...
tr[rowColor]
th[colConstructorName]
HashMap​(Map<? extendsK,​? extendsV> m)td[colLast]
div[block]
Constructs a newHashMapwith the same mappings as thespecifiedMap
li[blockList]
section[methodSummary]
- a[#method.summary]
h2
Method Summarydiv[memberSummary]
div
- button[activeTableTab#t0] All Methods
- button[tableTab#t2]
- button[tableTab#t4]
div[#memberSummary_tabpanel]
table
thead
tr
th[colFirst]
Modifier and Typeth[colSecond]
Methodth[colLast]
Description
tbody
tr[altColor#i0]
td[colFirst]
voidth[colSecond]
clear()td[colLast]
div[block]
Removes all of the mappings from this map.
tr[rowColor#i1]
td[colFirst]
Objectth[colSecond]
clone()td[colLast]
div[block]
Returns a shallow copy of thisHashMapinstance: the keys andvalues ...
tr[altColor#i2]
td[colFirst]
Vth[colSecond]
compute​(K key,BiFunction<? superK,​? superVtd[colLast]
div[block]
Attempts to compute a mapping for the specified key and its curre ...
tr[rowColor#i3]
td[colFirst]
Vth[colSecond]
computeIfAbsent​(K key,Function<? superK,​? e ...td[colLast]
div[block]
If the specified key is not already associated with a value (or i ...
tr[altColor#i4]
td[colFirst]
Vth[colSecond]
computeIfPresent​(K key,BiFunction<? superK,​ ...td[colLast]
div[block]
If the value for the specified key is present and non-null, attem ...
tr[rowColor#i5]
td[colFirst]
booleanth[colSecond]
containsKey​(Object key)td[colLast]
div[block]
Returnstrueif this map contains a mapping for thespecified key.
tr[altColor#i6]
td[colFirst]
booleanth[colSecond]
containsValue​(Object value)td[colLast]
div[block]
Returnstrueif this map maps one or more keys to thespecified valu ...
tr[rowColor#i7]
td[colFirst]
Set<Map.Entry<K,​V>>th[colSecond]
entrySet()td[colLast]
div[block]
Returns aSetview of the mappings contained in this map.
tr[altColor#i8]
td[colFirst]
Vth[colSecond]
get​(Object key)td[colLast]
div[block]
Returns the value to which the specified key is mapped,ornullif t ...
tr[rowColor#i9]
td[colFirst]
booleanth[colSecond]
isEmpty()td[colLast]
div[block]
Returnstrueif this map contains no key-value mappings.
tr[altColor#i10]
td[colFirst]
Set<K>th[colSecond]
keySet()td[colLast]
div[block]
Returns aSetview of the keys contained in this map.
tr[rowColor#i11]
td[colFirst]
Vth[colSecond]
merge​(K key,V value,BiFunction<? superV,̴ ...td[colLast]
div[block]
If the specified key is not already associated with a value or is ...
tr[altColor#i12]
td[colFirst]
Vth[colSecond]
put​(K key,V value)td[colLast]
div[block]
Associates the specified value with the specified key in this map ...
tr[rowColor#i13]
td[colFirst]
voidth[colSecond]
putAll​(Map<? extendsK,​? extendsV> m)td[colLast]
div[block]
Copies all of the mappings from the specified map to this map.
tr[altColor#i14]
td[colFirst]
Vth[colSecond]
remove​(Object key)td[colLast]
div[block]
Removes the mapping for the specified key from this map if presen ...
tr[rowColor#i15]
td[colFirst]
intth[colSecond]
size()td[colLast]
div[block]
Returns the number of key-value mappings in this map.
tr[altColor#i16]
td[colFirst]
Collection<V>th[colSecond]
values()td[colLast]
div[block]
Returns aCollectionview of the values contained in this map.
div[inheritedList]
h3
Methods declared in class java.util.AbstractMap- a[#methods.inherited.from.class.java.util.AbstractMap] equals,hashCode,toString
div[inheritedList]
h3
Methods declared in class java.lang.Object- a[#methods.inherited.from.class.java.lang.Object] finalize,getClass,notify,notifyAll,wait,wait,wait
div[inheritedList]
h3
Methods declared in interface java.util.Map- a[#methods.inherited.from.class.java.util.Map] equals,forEach,getOrDefault,hashCode,putIfAbsent,remove,replace,
section[details]
ul[blockList]
li[blockList]
section[constructorDetails]
h2
Constructor Detail- a[#constructor.detail]
ul[blockList]
li[blockList]
section[detail]
h3
HashMap- a[#(int,float)] public HashMap​(int initialCapacity,float lo ...
div[block]
Constructs an emptyHashMapwith the specified initialcapacity and ...dl
dt
Parameters:dd
initialCapacity- the initial capacitydd
loadFactor- the load factordt
Throws:dd
IllegalArgumentException- if the initial capacity is negativeor t ...
li[blockList]
section[detail]
h3
HashMap- a[#(int)] public HashMap​(int initialCapacity)
div[block]
Constructs an emptyHashMapwith the specified initialcapacity and ...dl
dt
Parameters:dd
initialCapacity- the initial capacity.dt
Throws:dd
IllegalArgumentException- if the initial capacity is negative.
li[blockList]
section[detail]
h3
HashMap- a[#()] public HashMap()
div[block]
Constructs an emptyHashMapwith the default initial capacity(16) a ...
li[blockListLast]
section[detail]
h3
HashMap- a[#(java.util.Map)] public HashMap​(Map<? extendsK,​? extendsV> ...
div[block]
Constructs a newHashMapwith the same mappings as thespecifiedMapdl
dt
Parameters:dd
m- the map whose mappings are to be placed in this mapdt
Throws:dd
NullPointerException- if the specified map is null
li[blockList]
section[methodDetails]
h2
Method Detail- a[#method.detail]
ul[blockList]
li[blockList]
section[detail]
h3
size- a[#size()] public int size()
div[block]
Returns the number of key-value mappings in this map.dl
dt
Specified by:dd
size in interface Map<K,​V>dt
Overrides:dd
size in class AbstractMap<K,​V>dt
Returns:dd
the number of key-value mappings in this map
li[blockList]
section[detail]
h3
isEmpty- a[#isEmpty()] public boolean isEmpty()
div[block]
Returnstrueif this map contains no key-value mappings.dl
dt
Specified by:dd
isEmpty in interface Map<K,​V>dt
Overrides:dd
isEmpty in class AbstractMap<K,​V>dt
Returns:dd
trueif this map contains no key-value mappings
li[blockList]
section[detail]
h3
get- a[#get(java.lang.Object)] public V get​(Object key)
div[block]
Returns the value to which the specified key is mapped,ornullif t ...dl
dt
Specified by:dd
get in interface Map<K,​V>dt
Overrides:dd
get in class AbstractMap<K,​V>dt
Parameters:dd
key- the key whose associated value is to be returneddt
Returns:dd
the value to which the specified key is mapped, ornullif this map ...dt
See Also:dd
put(Object, Object)
li[blockList]
section[detail]
h3
containsKey- a[#containsKey(java.lang.Object)] public boolean containsKey​(Object key)
div[block]
Returnstrueif this map contains a mapping for thespecified key.dl
dt
Specified by:dd
containsKey in interface Map<K,​V>dt
Overrides:dd
containsKey in class AbstractMap<K,​V>dt
Parameters:dd
key- The key whose presence in this map is to be testeddt
Returns:dd
trueif this map contains a mapping for the specifiedkey.
li[blockList]
section[detail]
h3
put- a[#put(java.lang.Object,java.lang.Object)]
- a[#put(K,V)] public V put​(K key,V value)
div[block]
Associates the specified value with the specified key in this map ...dl
dt
Specified by:dd
put in interface Map<K,​V>dt
Overrides:dd
put in class AbstractMap<K,​V>dt
Parameters:dd
key- key with which the specified value is to be associateddd
value- value to be associated with the specified keydt
Returns:dd
the previous value associated withkey, ornullif there was no mapp ...
li[blockList]
section[detail]
h3
putAll- a[#putAll(java.util.Map)] public void putAll​(Map<? extendsK,​? ex ...
div[block]
Copies all of the mappings from the specified map to this map.The ...dl
dt
Specified by:dd
putAll in interface Map<K,​V>dt
Overrides:dd
putAll in class AbstractMap<K,​V>dt
Parameters:dd
m- mappings to be stored in this mapdt
Throws:dd
NullPointerException- if the specified map is null
li[blockList]
section[detail]
h3
remove- a[#remove(java.lang.Object)] public V remove​(Object key)
div[block]
Removes the mapping for the specified key from this map if presen ...dl
dt
Specified by:dd
remove in interface Map<K,​V>dt
Overrides:dd
remove in class AbstractMap<K,​V>dt
Parameters:dd
key- key whose mapping is to be removed from the mapdt
Returns:dd
the previous value associated withkey, ornullif there was no mapp ...
li[blockList]
section[detail]
h3
clear- a[#clear()] public void clear()
div[block]
Removes all of the mappings from this map.The map will be empty a ...dl
dt
Specified by:dd
clear in interface Map<K,​V>dt
Overrides:dd
clear in class AbstractMap<K,​V>
li[blockList]
section[detail]
h3
containsValue- a[#containsValue(java.lang.Object)] public boolean containsValue​(Object value)
div[block]
Returnstrueif this map maps one or more keys to thespecified valu ...dl
dt
Specified by:dd
containsValue in interface Map<K,​V>dt
Overrides:dd
containsValue in class AbstractMap<K,​V>dt
Parameters:dd
value- value whose presence in this map is to be testeddt
Returns:dd
trueif this map maps one or more keys to thespecified value
li[blockList]
section[detail]
h3
keySet- a[#keySet()] public Set<K> keySet()
div[block]
Returns aSetview of the keys contained in this map.The set is bac ...dl
dt
Specified by:dd
keySet in interface Map<K,​V>dt
Overrides:dd
keySet in class AbstractMap<K,​V>dt
Returns:dd
a set view of the keys contained in this map
li[blockList]
section[detail]
h3
values- a[#values()] public Collection<V> values()
div[block]
Returns aCollectionview of the values contained in this map.The c ...dl
dt
Specified by:dd
values in interface Map<K,​V>dt
Overrides:dd
values in class AbstractMap<K,​V>dt
Returns:dd
a view of the values contained in this map
li[blockList]
section[detail]
h3
entrySet- a[#entrySet()] public Set<Map.Entry<K,​V>> entrySet( ...
div[block]
Returns aSetview of the mappings contained in this map.The set is ...dl
dt
Specified by:dd
entrySet in interface Map<K,​V>dt
Returns:dd
a set view of the mappings contained in this map
li[blockList]
section[detail]
h3
computeIfAbsent- a[#computeIfAbsent(java.lang.Object,java.util.function.Function)]
- a[#computeIfAbsent(K,java.util.function.Function)] public V computeIfAbsent​(K key,Function< ...
div[block]
If the specified key is not already associated with a value (or i ...dl
dt
Specified by:dd
computeIfAbsent in interface Map<K,​V>dt
Parameters:dd
key- key with which the specified value is to be associateddd
mappingFunction- the mapping function to compute a valuedt
Returns:dd
the current (existing or computed) value associated withthe speci ...dt
Throws:dd
ConcurrentModificationException- if it is detected that themappin ...
li[blockList]
section[detail]
h3
computeIfPresent- a[#computeIfPresent(java.lang.Object,java.util.function.BiFunction)]
- a[#computeIfPresent(K,java.util.function.BiFunction)] public V computeIfPresent​(K key,BiFunction
div[block]
If the value for the specified key is present and non-null, attem ...dl
dt
Specified by:dd
computeIfPresent in interface Map<K,​V>dt
Parameters:dd
key- key with which the specified value is to be associateddd
remappingFunction- the remapping function to compute a valuedt
Returns:dd
the new value associated with the specified key, or null if nonedt
Throws:dd
ConcurrentModificationException- if it is detected that theremapp ...
li[blockList]
section[detail]
h3
compute- a[#compute(java.lang.Object,java.util.function.BiFunction)]
- a[#compute(K,java.util.function.BiFunction)] public V compute​(K key,BiFunction<? supe ...
div[block]
Attempts to compute a mapping for the specified key and its curre ...dl
dt
Specified by:dd
compute in interface Map<K,​V>dt
Parameters:dd
key- key with which the specified value is to be associateddd
remappingFunction- the remapping function to compute a valuedt
Returns:dd
the new value associated with the specified key, or null if nonedt
Throws:dd
ConcurrentModificationException- if it is detected that theremapp ...
li[blockList]
section[detail]
h3
merge- a[#merge(java.lang.Object,java.lang.Object,java.util.function.BiFunction)]
- a[#merge(K,V,java.util.function.BiFunction)] public V merge​(K key,V value,BiFunctio ...
div[block]
If the specified key is not already associated with a value or is ...dl
dt
Specified by:dd
merge in interface Map<K,​V>dt
Parameters:dd
key- key with which the resulting value is to be associateddd
value- the non-null value to be merged with the existing valueass ...dd
remappingFunction- the remapping function to recompute a value if ...dt
Returns:dd
the new value associated with the specified key, or null if noval ...dt
Throws:dd
ConcurrentModificationException- if it is detected that theremapp ...
li[blockListLast]
section[detail]
h3
clone- a[#clone()] public Object clone()
div[block]
Returns a shallow copy of thisHashMapinstance: the keys andvalues ...dl
dt
Overrides:dd
clone in class AbstractMap<K,​V>dt
Returns:dd
a shallow copy of this mapdt
See Also:dd
Cloneable
footer
nav
div[bottomNav]
- a[#navbar.bottom]
div[skipNav]
Skip navigation links- a[#navbar.bottom.firstrow]
ul[navList]
li
Overviewli
Moduleli
Packageli[navBarCell1Rev]
Classli
Useli
Treeli
Deprecatedli
Indexli
Help
div[aboutLanguage]
div
Java SE 13 & JDK 13DRAFT 13-internal+0-2019-04-09-0725291.pri ...
div[subNav]
div
ul[subNavList]
li
Summary: li
Nested | li
Field | li
Constr | li
Method
ul[subNavList]
li
Detail: li
Field | li
Constr | li
Method
- a[#skip.navbar.bottom]
Report a bug or suggest an enhancementFor further API reference a ...