Here you can find the source of union(Collection
public static <T> Collection<T> union(Collection<T> set1, Collection<T> set2)
//package com.java2s; import java.util.*; public class Main { public static <T> Collection<T> union(Collection<T> set1, Collection<T> set2) { Collection<T> union = new ArrayList<>(); for (T t : set1) { union.add(t);//from www . jav a 2 s.co m } for (T t : set2) { union.add(t); } return union; } }