Java Set Create asSet(Collection c)

Here you can find the source of asSet(Collection c)

Description

as Set

License

Open Source License

Parameter

Parameter Description
c a parameter

Return

a c if c is a or, otherwise, a containing the elements of c

Declaration

public static <T> Set<T> asSet(Collection<T> c) 

Method Source Code

//package com.java2s;

import java.util.*;

public class Main {
    /**//  ww w.j a  va  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> asSet(Collection<T> c) {
        if (c instanceof Set) {
            return (Set<T>) c;
        }
        LinkedHashSet<T> set = new LinkedHashSet<T>(c);
        return set;
    }
}

Related

  1. asSet(Collection c)
  2. asSet(Collection c)
  3. asSet(E... elements)
  4. asSet(E... pEntities)
  5. asSet(final E... elements)
  6. asSet(final T t, final T... ts)