What does EnumSet really mean?

后端 未结 10 1505
小蘑菇
小蘑菇 2020-12-04 16:08

I have the following example:

import java.util.EnumSet;
import java.util.Iterator;

public class SizeSet {

    public static void main(String[] args) {
             


        
10条回答
  •  失恋的感觉
    2020-12-04 16:40

    EnumSet largeSize
    

    EnumSet largeSize is a set of Enum values which contains XL, XXL and XXXL.

    Size 
    

    Size is a class of Enum type with constant values S, M, L, XL, XXL, XXXL.

    largeSize.iterator()
    

    The Iterator for EnumSet is in natural order, the order in which the values of the enum were originally declared.

    • EnumSet class is a member of the Java Collections Framework & is not synchronized.
    • Its a high performance set implementation, they are much faster than HashSet.
    • All elements of each EnumSet instance must be elements of a single enum type.

    To Know more read the api doc : http://docs.oracle.com/javase/8/docs/api/java/util/EnumSet.html

提交回复
热议问题