Java tutorial
//package com.java2s; import java.util.*; public class Main { public static <E> Set<E> asSet(E... elements) { if (elements == null || elements.length == 0) { return Collections.emptySet(); } LinkedHashSet<E> set = new LinkedHashSet<E>(elements.length * 4 / 3 + 1); Collections.addAll(set, elements); return set; } }