Here you can find the source of Union(ArrayList
Parameter | Description |
---|---|
list1 | First list |
list2 | Second list |
public static ArrayList<String> Union(ArrayList<String> list1, ArrayList<String> list2)
//package com.java2s; // it under the terms of the GNU General Public License as published by import java.util.*; public class Main { /** Finds the union of two lists of String objects *// w w w .j av a 2 s . c om * @param list1 First list * @param list2 Second list * @return Union list (contains values that exist in either list) */ public static ArrayList<String> Union(ArrayList<String> list1, ArrayList<String> list2) { Set union = new HashSet(list1); union.addAll(new HashSet(list2)); return new ArrayList(union); } }