Difference between HashMap, LinkedHashMap and TreeMap

后端 未结 17 2137
醉话见心
醉话见心 2020-11-22 01:01

What is the difference between HashMap, LinkedHashMap and TreeMap in Java? I don\'t see any difference in the output as all the three

17条回答
  •  长发绾君心
    2020-11-22 01:33

    HashMap

    • It has pair values(keys,values)
    • NO duplication key values
    • unordered unsorted
    • it allows one null key and more than one null values

    HashTable

    • same as hash map
    • it does not allows null keys and null values

    LinkedHashMap

    • It is ordered version of map implementation
    • Based on linked list and hashing data structures

    TreeMap

    • Ordered and sortered version
    • based on hashing data structures

提交回复
热议问题