Java Class that implements Map and keeps insertion order?

后端 未结 9 2278
一向
一向 2020-11-22 11:28

I\'m looking for a class in java that has key-value association, but without using hashes. Here is what I\'m currently doing:

  1. Add values to a Hashtable<
9条回答
  •  无人共我
    2020-11-22 11:32

    You can maintain a Map (for fast lookup) and List (for order) but a LinkedHashMap may be the simplest. You can also try a SortedMap e.g. TreeMap, which an have any order you specify.

提交回复
热议问题