+ 2
How to access nested hashmap value?
Map<String , Map<String, Object>>
4 Answers
+ 2
If you have it defined like this:
Map<String , Map<String, Integer>> map1 = HashMap<>();
You can get value from inner map like this:
Object value = map1.get("outerKey").get("innerKey");
which is equal to
Map<String, Object> innerMap = map1.get("outerKey");
Object value = innerMap.get("innerKey");
+ 1
Thank you...
+ 1
I got better one here...
Map<Float, Map<Float, Integer>> map = new HashMap<>();
map.put(.0F, new HashMap(){{put(.0F,0);}});
map.put(.1F, new HashMap(){{put(.1F,1);}});
map.get(.0F).get(.0F);
0
How can I read the integer value only from the inner Map?