Java Set Create toSet(Object[] someElements)

Here you can find the source of toSet(Object[] someElements)

Description

to Set

License

Open Source License

Declaration

public static Set toSet(Object[] someElements) 

Method Source Code

//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]);//from  w ww.  ja  v  a 2 s  .c  o  m

        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;
    }
}

Related

  1. asSet(T... ts)
  2. asSet(T... values)
  3. asSet(T... values)
  4. toSet(Iterable things)
  5. toSet(Iterable items)
  6. toSet(Set set)
  7. toSet(String[] aStringArray)
  8. toSet(T... objects)
  9. unmodifiableSet(final Set s, final boolean newSet, final boolean emptyAsNull)