Hashtable: inherits from the dictionary class and implements the map interface. The key or value is not allowed to be empty and the thread is synchronized;
Hashmap: inherits from the abstractmap class and implements the map interface. The key or value is null and the thread is not synchronized;
Linkedhashmap: inherits from the hashmap class, implements the map interface, allows the key or value to be empty, and stores the record insertion sequence, the thread is not synchronized.
Treemap: inherits from the abstractmap class and implements the sortedmap interface. It can sort by key or specify the sort comparator (implement the comparator interface ).
If you want map synchronization, you can use the synchronizedmap method in collections.
Note: If the result is stored in hashmap, it is very different from the sorting result in the database, because hashmap sorts the result by the hash value of its key. It is best to use linkedhashmap, it inherits hashmap and maintains a two-way linked list (specifically a circular linked list), which is used to record the current element, the previous element, and its next element, therefore, you can record the order in which it is added.
Comparison of hashtable, hashmap, linkedhashmap, and treemap