Java中HashMap,LinkedHashMap,WeakHashMap,HashTable,TreeMap等的区别?
阿神
阿神 2017-04-18 09:48:24
0
2
773

Java中

HashMap
LinkedHashMap
WeakHashMap
HashTable
IdentityHashMap
TreeMap

的区别?

和它们各自的实现特点
比如HashMap用数组和链表来保存等。

阿神
阿神

闭关修行中......

reply all (2)
黄舟

I wonder if you have ever learned data structure?

    大家讲道理

    HashMap: Map (Key-Value) type implemented based on Hash table
    TreeMap: Ordered Map (based on natural sorting of keys)
    LinkedHashMap: Ordered Map (based on insertion order sorting)
    WeakHashMap: Weak only holding keys Reference, so when the key is recycled, the record corresponding to the key can be automatically deleted.
    IdentityHashMap: Generally, in Map implementation, if the key values are equal (equals is true), they are considered to be the same key. This Map uses the same object (reference) as the basis for judgment, and is not officially recommended for use.
    HashTable: Similar to HashMap, key or value can be null, thread-safe, old-fashioned implementation.
    Finally, I suggest that if you have this kind of problem, you can directly read the Java SE manual, which has a detailed introduction: Java SE API

      Latest Downloads
      More>
      Web Effects
      Website Source Code
      Website Materials
      Front End Template
      About us Disclaimer Sitemap
      php.cn:Public welfare online PHP training,Help PHP learners grow quickly!