Java HashMap Counter incrementHashMap(HashMap map, String key, int n)

Here you can find the source of incrementHashMap(HashMap map, String key, int n)

Description

increment Hash Map

License

Apache License

Declaration

public static void incrementHashMap(HashMap map, String key, int n) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.util.HashMap;

public class Main {
    public static void incrementHashMap(HashMap map, String key, int n) {
        int count;
        Integer countI = (Integer) map.get(key);
        if (countI == null)
            count = 0;/* ww  w. j  av  a2  s  .co m*/
        else {
            count = countI;
        }
        map.put(key, count + n);
    }
}

Related

  1. increment(HashMap m, X key)
  2. incrementMap(HashMap map, Integer key)
  3. incrementTwoLevelHashMap(HashMap map, String key1, String key2, int n)