0

I have the following HashMap where the key is String and value is represented by a HashMap.

HashMap<String, HashMap<String, Integer>  outerMap = new  HashMap<String,HashMap<String, Integer>();
HashMap<String, Integer> innerMap = new HashMap<String, Integer>();
innerMap.put("Amount", 2000);
outerMap.put("TutionFee", innerMap);

Now I want to update the value of Amount key. How can I update the value of Amount key?

Biffen
  • 6,249
  • 6
  • 28
  • 36
  • Check [How to update a value, given a key in a java hashmap?](http://stackoverflow.com/questions/4157972/how-to-update-a-value-given-a-key-in-a-java-hashmap) – sam Nov 06 '15 at 14:35

2 Answers2

2

This should work:

outerMap.get("TutionFee").put("Amount", newValue);
Dragonmon
  • 114
  • 6
0

Suppose new value to update is 1000, then outerMap.get("TutionFee").put("Amount", 1000);

Tsung-Ting Kuo
  • 1,171
  • 6
  • 16
  • 21