Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static <T, U> void mapMergeAdd(Map<T, List<U>> map, Map<T, List<U>> mapToAdd) {
        for (Map.Entry<T, List<U>> e : mapToAdd.entrySet()) {
            if (!map.containsKey(e.getKey())) {
                map.put(e.getKey(), new ArrayList<U>());
            }
            map.get(e.getKey()).addAll(e.getValue());
        }
    }
}