Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Open Source License 

import java.util.Map;
import java.util.Map.Entry;

public class Main {
    public static <TKey extends TKeyT, TKeyT> Map<? super TKey, Integer> mergeMapWithAdd(Map<TKeyT, Integer> target,
            Map<? extends TKey, ? extends Integer> source) {
        for (Entry<? extends TKey, ? extends Integer> entry2 : source.entrySet()) {
            TKey key2 = entry2.getKey();
            int val2 = entry2.getValue();
            if (target.containsKey(key2)) {
                int val1 = target.get(key2);
                target.put(key2, val1 + val2);
            } else {
                target.put(key2, val2);
            }
        }
        return target;
    }
}