Here you can find the source of asSet(T... elements)
Parameter | Description |
---|---|
elements | the elements. |
T | the element type. |
Parameter | Description |
---|---|
NullPointerException | if parameter elements is null. |
public static <T> Set<T> asSet(T... elements)
//package com.java2s; //License from project: Apache License import java.util.LinkedHashSet; import java.util.Set; import static java.util.Collections.addAll; public class Main { /**//from w w w. ja v a 2s .c o m * Creates a {@link java.util.Set} with the given elements. * * @param elements the elements. * @param <T> the element type. * @return a new {@link java.util.Set} instance containing the given elements. * @throws NullPointerException if parameter elements is {@code null}. */ public static <T> Set<T> asSet(T... elements) { final Set<T> resultSet = new LinkedHashSet<T>(); addAll(resultSet, elements); return resultSet; } }