Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Collection; import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; public class Main { @SafeVarargs public static <T> Set<T> unionArraysAsSet(T[]... arrays) { return Stream.of(arrays).map(Arrays::asList).flatMap(Collection::stream).collect(Collectors.toSet()); } }