Java tutorial
//package com.java2s; import java.util.ArrayList; import java.util.List; public class Main { public static <T> List<T> union(List<T> a, List<T> b) { List<T> result = new ArrayList<>(); List<T> alls = new ArrayList<>(a); alls.addAll(b); for (T t : alls) { boolean has = false; for (T r : result) { if (r.equals(t)) { has = true; break; } } if (!has) { result.add(t); } } return result; } }