Java tutorial
//package com.java2s; /* * CrimsonGlow is an adult computer roleplaying game with spanking content. * Copyright (C) 2015 Andrew Russell * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ import java.util.LinkedHashMap; import java.util.Map; public class Main { /** * Given two maps with disjoint key sets, merges them and returns the merged map. * * @param map1 The first map to merge * @param map2 The second map to merge * @param <T> The key type of the maps * @param <U> The value type of the maps * * @return A new map that is the merger of the two parameters */ public static <T, U> LinkedHashMap<T, U> mergeMaps(Map<T, U> map1, Map<T, U> map2) { LinkedHashMap<T, U> newMap = new LinkedHashMap<>(map1); newMap.putAll(map2); return newMap; } }