Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.Arrays; import java.util.Set; import java.util.stream.Collectors; public class Main { @SafeVarargs public static <T> Set<T> setOfNotNull(T... objects) { return Arrays.stream(objects).filter(obj -> obj != null).collect(Collectors.toSet()); } }