Java EnumSet create

Description

Java EnumSet create


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

enum Letter {//w  ww .  jav  a2 s .c  o m
  S, M, L, X, A, B;
}

public class Main {

  public static void main(String[] args) {
    EnumSet<Letter> largeSize = EnumSet.of(Letter.X, Letter.A, Letter.B);
    for (Iterator<Letter> it = largeSize.iterator(); it.hasNext();) {
      Letter size = (Letter) it.next();
      System.out.println(size);
    }
  }
}



PreviousNext

Related