public static HashMap<ArrayList<Integer>, String> map = new HashMap<ArrayList<Integer>, String>();
public static ArrayList<ArrayList<Integer>> keys = new ArrayList<>(map.keySet());
Then in main
map.put(key, "c");
(assume key is a valid ArrayList). But keys still has size 0 after that.
How can I make the relationship of keys stronger so that it will be actually tied to the HashMap and contain all its keys.
You can’t.
Map.keySet()returns the Map’s current key set, which you then load into your list. Changes to the map after that have no effect on the contents of the list.Most people would just re-get the key set if needed. Why don’t you just do that?