+ 2

How to access nested hashmap value?

Map<String , Map<String, Object>>

19th Jan 2017, 5:34 PM
Faruque Hossain
Faruque Hossain  - avatar
4 Antworten
+ 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");
19th Jan 2017, 9:43 PM
Josip Tomić
Josip Tomić - avatar
+ 1
Thank you...
20th Jan 2017, 3:10 PM
Faruque Hossain
Faruque Hossain  - avatar
+ 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);
20th Jan 2017, 9:20 PM
Faruque Hossain
Faruque Hossain  - avatar
0
How can I read the integer value only from the inner Map?
19th Nov 2017, 1:17 PM
Dharshan Siva
Dharshan Siva - avatar