Java tutorial
//package com.java2s; import java.util.Collection; import java.util.HashSet; import java.util.Set; public class Main { /** * Returns union of two collections. * * @param <T> the generic type * @param coll1 the coll1 * @param coll2 the coll2 * @return the collection */ public static <T> Collection<T> union(Collection<T> coll1, Collection<T> coll2) { Set<T> union = new HashSet<T>(coll1); union.addAll(new HashSet<T>(coll2)); return union; } }