Java tutorial
//package com.java2s; import java.util.Collections; import java.util.HashSet; public class Main { public static <T> HashSet<T> toHashSet(T[] items) { if (items == null || items.length == 0) return null; HashSet<T> set = new HashSet<>(); Collections.addAll(set, items); return set; } }