HashMap
Posted bitreea
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了HashMap相关的知识,希望对你有一定的参考价值。
Class HashMap<K,V>
1.包:java.util;
2.K-键,V-值
3.构造方法:
HashMap();
HashMap(int initialCapacity)
HashMap(int initialCapacity,float loadFactor)
HashMap(Map<?extends K,?extends V>m)
4.常用方法:
(1)clear()
Removes all of the mappings from this map
(2)containsKey(Object key)
Returns true if this map contains a mapping for the specified key.
(3)containsValue(Object value)
Returns true if this map maps one or more keys to the specified value.
(4)get(Object key)
Returns the value to which the specified key is mapped, or null
if this map contains no mapping for the key.
(5)isEmpty()
Returns true if this map contains no key-value mappings.
(6)put(K key,V value)
Associates the specified value with the specified key in this map.
(7)size()
Returns the number of key-value mappings in this map.
以上是关于HashMap的主要内容,如果未能解决你的问题,请参考以下文章