Here you can find the source of toSet(Object[] someElements)
public static Set toSet(Object[] someElements)
//package com.java2s; //License from project: Open Source License import java.util.*; public class Main { public static Set toSet(Object[] someElements) { Set asSet = new HashSet(someElements.length); for (int i = 0; i < someElements.length; i++) asSet.add(someElements[i]);//from w ww. ja v a 2 s .c o m return asSet; } public static Set toSet(List someElements) { Set asSet = new HashSet(someElements.size()); for (int i = 0; i < someElements.size(); i++) asSet.add(someElements.get(i)); return asSet; } }