I would like to know the best data structure used in java suitable for the following senario.
There is a key and a value.
And the key is not duplicated,
Each Value should store collection of objects where the values in each object will change frequently.
Thanks.
解决方案
HashMap should serve your need.
HashMap allows you to store key value pairs as a collection. HashMap does not allow duplicate keys. You can use different collection to be stored as a value in your HashMap. For example to create a map with keys as a String and value as a list, the define it like this:
Map> = new HashMap>();
Also there are implementations for such collection called MultiMap i.e map where a key is associated with collection of values. Two popular implemantations of MultiMap are:
Apacha MultiMap
Guava MultiMap