new HashSet(Collection c) : HashSet « java.util « Java by API






new HashSet(Collection c)

 
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

public class Main {

  public static void main(String[] args) {
    List<String> myList = new ArrayList<String>();
    myList.add("Hello");
    myList.add("World");
    myList.add("World");
    Set<String> set = new HashSet<String>(myList);

    System.out.println(set);
  }

}

   
  








Related examples in the same category

1.new HashSet < E > ()
2.HashSet: add(E o)
3.HashSet: addAll(Collection c)
4.HashSet: clear()
5.HashSet: clone()
6.HashSet: contains(Object o)
7.HashSet: containsAll(Collection c)
8.HashSet: isEmpty()
9.HashSet: iterator()
10.HashSet: removeAll(Collection c)
11.HashSet: size()
12.HashSet: toArray()