Map
A Map
is a data structure consisting of a set of keys and values in which each key is mapped to a single value. The class of the objects used as keys is declared when the Map
is declared, as is the class of the corresponding values.
A Map
provides helper methods to iterate through all of the keys contained in it, as well as various methods to access and update the key/value pairs.
Map方法提供多种辅助方法去迭代它所包含的所有关键词,和各种方法去访问和跟新关键词-——值(Key/Value)对。
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
abstract void |
clear()
从Map中移除所有元素,让其保持空集
| ||||||||||
abstract boolean |
containsKey(
Object key)
返回是否Map中含有指定的关键词 | ||||||||||
abstract boolean |
containsValue(
Object value)
返回是否Map中含有指定的值
| ||||||||||
abstract Set< Entry<K, V>> |
entrySet()
返回一个该Map所包含的所有映射的一个集合
| ||||||||||
abstract boolean |
equals(
Object object)
判断指定的Map和多对比的Map所包含的内容是否完全一样
| ||||||||||
abstract V |
get(
Object key)
返回指定关键词所对应的值
| ||||||||||
abstract int |
hashCode()
为接收者返回一个整数的散列码
| ||||||||||
abstract boolean |
isEmpty()
判断Map是否为空
| ||||||||||
abstract Set<K> |
keySet()
返回该Map中的关键词集合
| ||||||||||
abstract V |
put(K key, V value)
将关键词映射到指定的关键值
| ||||||||||
abstract void |
putAll(
Map<? extends K, ? extends V> map)
将指定的Map中的每一项复制到另一个Map中
| ||||||||||
abstract V |
remove(
Object key)
将指定的关键词所对应的项从Map中移除
| ||||||||||
abstract int |
size()
返回该Map中所包含项目的个数
| ||||||||||
abstract Collection<V> |
values()
返回该Map中值所组成的一个Collection
|