Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Map;

public class Main {
    /**
     * @param <T>
     * @param aMap
     * @param aKey
     * @return New Count Value
     */
    public static <T> int incrementCount(Map<T, Integer> aMap, T aKey) {
        return incrementCount(aMap, aKey, 1);
    }

    /**
     * @param <T>
     * @param aMap
     * @param aKey
     * @param aCount
     * @return New Count Value
     */
    public static <T> int incrementCount(Map<T, Integer> aMap, T aKey, Integer aCount) {
        Integer count = aMap.get(aKey);
        if (count == null) {
            count = 0;
        }

        int newCount = count + aCount;
        aMap.put(aKey, newCount);
        return newCount;
    }
}