import java.util.EnumSet;
public final class EnumMeg
{
public static void main(String[] args)
{
Integer i = null;
method(i);
}
static void method(int k){
System.out.println(k);
}
}

It will compile but will throw a NullPointerException at runtime.

  • Share/Bookmark

What is the java.util.EnumSet set?

The java.util.EnumSet set is a special purpose set. It is used to provide an implementation for better performance for enum types. It is necessray that the elements in an enum set must come from a single enum type that is specified, explicitly or implicitly, when the set is created. They are represented internally as bit vectors. This representation is extremely compact and efficient.

  • Share/Bookmark