Java CollectionFrameWork -- Map

一、java集合框架类之Map

Map是一种常见的集合类,存储的元素是几月键值树对的形式即:key-->value ,这种形式的元素对。

      Map作为一个接口,定义了如下的通用的方法:public interface Map<K,V>

int size();//return the number of key-value mappings in this map

boolean isEmpty();//return true if this map contains no key-value mappings

boolean containsKey(Object key);//return true if this map contains a mapping for the specified key

boolean containsValue(Object value);//return true if this map maps one or more keys to the specified value

V get(Object key);//return the value to which the specified key is mapped, or null if this map contains no                                                       mapping for the key

V put(Key key, V value);

V remove(Object key);//return the previous value associated with key, or null if there was no mapping for key

void putAll(Map<? extends K, ? extends V> m);//copies all of the mappings from the map m to this map.

void clear();//Removes all of the mappings from this map

Set<K> keySet();// return a view of the keys contained in this map.

Collection<V> valus();// return a view of the values contained int this map.

Set<Map.Entry<K,V>> entrySet();//return a set view of the mappings contained int this map.

然后,包含一个内部接口:

interface Entry<K,V> {

K  getKey();

V  getValue();

     V  setValye(V valye);

boolean equals(Object o);

int hashCode();

}

/

然后是抽象的AbstractMap<K,V> 实现了Map接口,AbstractMap抽象了Map这个事物,提供了Map接口的骨干实现,从而最大限度的减少了实现此接口所需要的工作。

直接已知子类有:ConcurrentHashMap,EnumMap,HashMap,IdentifyHashMap,TreeeMap,WeakHashMap.

        接下来的几节中,分别介绍具体的子类及其特点。

        下一篇介绍:HashMap

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值