Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.HashMap;
import java.util.Map;

public class Main {
    public static <K> Map<K, Integer> uniomCounterMap(Map<K, Integer> first, Map<K, Integer> second) {
        Map<K, Integer> ret = new HashMap<K, Integer>(first);
        for (K key : second.keySet()) {
            if (ret.containsKey(key)) {
                ret.put(key, ret.get(key) + second.get(key));
            } else {
                ret.put(key, second.get(key));
            }
        }
        return ret;
    }
}