2019年7月18日

22.如何决定使用 HashMap 还是 TreeMap?

摘要: TreeMap<K,V>的Key值是要求实现java.lang.Comparable,所以迭代的时候TreeMap默认是按照Key值升序排序的;TreeMap的实现也是基于红黑树结构。 而HashMap<K,V>的Key值实现散列hashCode(),分布是散列的均匀的,不支持排序;数据结构主要是桶 阅读全文

posted @ 2019-07-18 11:58 天天天12345 阅读(355) 评论(0) 推荐(0) 编辑

21.HashMap 和 Hashtable 有什么区别?

摘要: 1、HashMap是继承自AbstractMap类,而HashTable是继承自Dictionary类。不过它们都实现了同时实现了map、Cloneable(可复制)、Serializable(可序列化)这三个接口。 2、Hashtable比HashMap多提供了elments() 和contain 阅读全文

posted @ 2019-07-18 11:49 天天天12345 阅读(254) 评论(0) 推荐(0) 编辑

导航