Here you can find the source of toSet(Collection
Parameter | Description |
---|---|
c | a parameter |
public static <T> Set<T> toSet(Collection<T> c)
//package com.java2s; import java.util.*; public class Main { /**/*from ww w . j a v a 2 s . co m*/ * @param c * @return a c if c is a {@link Set} or, otherwise, a {@link LinkedHashSet} * containing the elements of c */ public static <T> Set<T> toSet(Collection<T> c) { return asSet(c); } /** * @param c * @return a c if c is a {@link Set} or, otherwise, a {@link LinkedHashSet} * containing the elements of c */ public static <T> Set<T> asSet(Collection<T> c) { if (c instanceof Set) { return (Set<T>) c; } LinkedHashSet<T> set = new LinkedHashSet<T>(c); return set; } }