Create an empty Set in Java

Description

The following code shows how to create an empty Set.

Example


/*from www .j  a  v a  2  s  . c  om*/
import java.util.Collections;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class Main {
  public static void main(String args[]) {
    Set set = Collections.EMPTY_SET;
    Set<Long> l = Collections.emptySet();

  }
}




















Home »
  Java Tutorial »
    Java Collection »




Java ArrayList
Java Collection
Java Comparable
Java Comparator
Java HashMap
Java HashSet
Java Iterator
Java LinkedHashMap
Java LinkedHashSet
Java LinkedList
Java List
Java ListIterator
Java Map
Queue
Java Set
Stack
Java TreeMap
TreeSet