Java examples for java.util:Set Union
union two Sets and return a new Set
//package com.java2s; import java.util.HashSet; import java.util.Set; public class Main { public static <T> Set<T> union(Set<T> set1, Set<T> set2) { Set<T> set = new HashSet<>(); set.addAll(set1);// ww w . j a va2 s. c o m set.addAll(set2); return set; } }