Here you can find the source of mergeLists(List
public static <T> List<T> mergeLists(List<T> copyTo, List<T> copyFrom)
//package com.java2s; /*/*w ww .ja va 2s.co m*/ * Copyright (c) 2016 VMware, Inc. All Rights Reserved. * * This product is licensed to you under the Apache License, Version 2.0 (the "License"). * You may not use this product except in compliance with the License. * * This product may include a number of subcomponents with separate copyright notices * and license terms. Your use of these subcomponents is subject to the terms and * conditions of the subcomponent's license, as noted in the LICENSE file. */ import java.util.List; public class Main { public static <T> List<T> mergeLists(List<T> copyTo, List<T> copyFrom) { if (copyTo == null) { return copyFrom; } else if (copyFrom != null && !copyFrom.isEmpty()) { for (T t : copyTo) { if (!copyFrom.contains(t)) { copyFrom.add(t); } } return copyFrom; } return copyTo; } }