Here you can find the source of union(final List
public static <E> List<E> union(final List<E> list1, final List<E> list2)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static <E> List<E> union(final List<E> list1, final List<E> list2) { if (list1 == null || list2 == null) throw new NullPointerException("Not initizalized lists"); List<E> concat = new ArrayList<E>(list1.size() + list2.size()); concat.addAll(list1);/*from w ww .ja v a 2 s .com*/ E item; ListIterator<E> iter = list1.listIterator(); while (iter.hasNext()) { item = iter.next(); if (!concat.contains(item)) { concat.add(item); } } return concat; } }