JavaSe——9、Map家族

来源:互联网 发布:lrc制作软件 编辑:程序博客网 时间:2024/06/10 13:10

Map

特性:

  • 和Set很像,value为null的Map就是Set。entrySet、keySet方法可以返回set集合。

  • Map下的HashMap、LinkedHashMap、SortedMap、TreeMap、EnumMap对应于Set的HashSet、LinkedHashSet、SortedSet、TreeSet等。

  • Map的put如果重复了key,则会覆盖value,并返回被覆盖前的value。
    Map重写了toString();可以返回key=xx,value=yy

重要源码:

public interface Map<K,V> {    int size();    boolean isEmpty();    //内部接口    interface Entry<K,V> {}

HashMap

特性:

原创粉丝点击