Here you can find the source of join(List
public static List<String> join(List<String> list1, List<String> list2)
//package com.java2s; /* //from w w w. j av a 2 s . c om * ScreenSlicer (TM) -- automatic, zero-config web scraping (TM) * Copyright (C) 2013-2015 Machine Publishers, LLC * ops@machinepublishers.com | screenslicer.com | machinepublishers.com * Cincinnati, Ohio, USA * * You can redistribute this program and/or modify it under the terms of the * GNU Affero General Public License version 3 as published by the Free * Software Foundation. Additional permissions or commercial licensing may be * available--see LICENSE file or contact Machine Publishers, LLC for details. * * 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 Affero General Public License version 3 * for more details. * * You should have received a copy of the GNU Affero General Public License * version 3 along with this program. If not, see <http://www.gnu.org/licenses/>. * * For general details about how to investigate and report license violations, * please see: https://www.gnu.org/licenses/gpl-violation.html * and email the author: ops@machinepublishers.com * Keep in mind that paying customers have more rights than the AGPL alone offers. */ import java.util.ArrayList; import java.util.List; public class Main { public static List<String> join(List<String> list1, List<String> list2) { List<String> list = new ArrayList<String>(); for (String cur : list1) { if (!list.contains(cur)) { list.add(cur); } } for (String cur : list2) { if (!list.contains(cur)) { list.add(cur); } } return list; } public static boolean contains(List<String> list, List<List<String>> listOfLists) { for (List<String> cur : listOfLists) { if (isSame(list, cur)) { return true; } } return false; } public static boolean isSame(List<String> lhs, List<String> rhs) { if (lhs == null && rhs == null) { return true; } if (lhs == null) { return false; } if (rhs == null) { return false; } if (lhs.size() != rhs.size()) { return false; } for (int i = 0; i < lhs.size(); i++) { if (!lhs.get(i).equals(rhs.get(i))) { return false; } } return true; } }