Java tutorial
//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]); 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; } }