LinkedHashMap<String,ArrayList<String>> h;
It contains:
key 1 : value A, B, C, D
2 : E,F
3 : G
I don’t quite understand the Set interface. Maybe a little visualization would help. Please help me to visualize how would all these elements inside LinkedHashMap look like once I convert them into Set?
Set set = h.entrySet();
Sorry, maybe my question is a little obscure. I will try to sharpen it as the thread develops.
The entry-set of a
Mapis the set of entries in the map.An entry in a map is a mapping from key to value. In your case where the map is of type
...<String, ArrayList<String>>, an single entry is a pair of aString(the key) and anArrayList<String>(the value).The following snippet may shed some light on this:
Output:
In this case for instance, the entry set is actually an inner class of
HashMap, namedEntrySet.