I have a HashMap 1 that contains 5 keys, all of which have Hashmaps values. I want to add key / value pairs to these sub-Maps.
map1.get(subCategoryMap).put(newKey, newValue);
My thinking:
map1.get(subCategoryMap);
returns another card. I could split this line into two lines and have:
map2 = map1.get(subCategoryMap);
map2.put(newKey, newValue);
But I would prefer to do it in one step. That's why i try
map1.get(subCategoryMap).put(newKey, newValue);
This does not work (do not like .put () for the object). Is it possible to access the sub-map and add to it in the same line of code as me, or do I need to split it into two lines?
source
share