Is there a better key value list than hashmap?

I have heard that hashmap takes up a lot of space and its access efficiency is not high. Is there a better data type such as < key, value > for scenarios that do not need to modify and delete operations (such as building API with gson)?

May.28,2021

this is the fastjson constructor code

 
I heard that hashmap takes up a lot of space and access efficiency is not high

because it is HashMap , 25% of the space in the underlying array of hashcode, is wasted by default in data access.
but this is in order to have good random access ability

.

that is to say, if there is no need for random access, HashMap is indeed wasteful. For example, ArrayMap on Android is designed for scenarios with "no random access"

.

in addition, there are things like MultiValueMap , IntMap , which also provide special functions or special optimizations for special scenarios (although none of them are native to jdk)

Menu