繁体   English   中英

更新HashMap中指定键的值

[英]Update the value of specified key in HashMap

我有以下HashMap,其中键为String,值由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);

现在,我想更新Amount键的值。 如何更新Amount键的值?

这应该工作:

outerMap.get("TutionFee").put("Amount", newValue);

假设要更新的新值为1000,则outerMap.get("TutionFee").put("Amount", 1000);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM