Here you can find the source of toSet(final TYPE[] array)
public static <TYPE> Set<TYPE> toSet(final TYPE[] array)
//package com.java2s; import java.util.Collections; import java.util.HashSet; import java.util.Set; public class Main { public static <TYPE> Set<TYPE> toSet(final TYPE[] array) { if (array == null) { return Collections.emptySet(); }//from www . j ava 2s . co m final Set<TYPE> result = new HashSet<TYPE>(); for (int i = 0; i < array.length; i++) { result.add(array[i]); } return result; } }