當前位置:編程學習大全網 - 網站源碼 - java 哈希表裏的值想加1怎麽辦

java 哈希表裏的值想加1怎麽辦

妳這是什麽結構?

hashTable?

hashSet?

hashMap?

Map<String,Integer> oldMap = new HashMap<String, Integer>();

oldMap.put("one", 1);

oldMap.put("two", 2);

oldMap.put("three", 3);

oldMap.put("four", 4);

Map<String,Integer> newMap = new HashMap<String, Integer>();

for (Map.Entry<String, Integer> mapVal : oldMap.entrySet()) {

int i = mapVal.getValue();

newMap.put(mapVal.getKey(), ++i);

}

//獲得新的newMap

  • 上一篇:民眾投顧與中廣資本是壹家嗎
  • 下一篇:如何把apk反編譯成java代碼
  • copyright 2024編程學習大全網