我有以下 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);
关于java - 更新HashMap中指定key的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33569063/