Java tutorial
//package com.java2s; //License from project: Open Source License import java.util.HashSet; import java.util.Set; public class Main { public static <T> Set<T> toUniqueSet(T[] array) { HashSet<T> set = new HashSet<T>(); if (array != null) { for (T object : array) { if (!set.contains(object)) { set.add(object); } } } return set; } }