EnumSet

 A specialized Set implementation for use with enum types. All of the elements in an enum set
 must come from a single enum type that is specified, explicitly or implicitly, when the set is created.
 Enum sets are represented internally as bit vectors. This representation is extremely compact and efficient.

 The space and time performance of this class should be good enough to allow its use as a high-quality,
 typesafe alternative to traditional int-based "bit flags." Even bulk operations (such as containsAll and
 retainAll) should run very quickly if their argument is also an enum set.

package collection.demos;



import java.util.EnumSet;

public class EnumSetDemo {

    enum keys{

        k1,k2,k3;

    }

    public static void main(String[] args) {

        EnumSet<keys> es=EnumSet.allOf(keys.class);

        System.out.println("EnumSet : "+es);

    }

}

No comments:

Popular Posts