Java wstaw elementy do wyliczenia
import java.util.EnumSet;
class Main {
enum Size {
SMALL, MEDIUM, LARGE, EXTRALARGE
}
public static void main(String[] args) {
// Creating an EnumSet using allOf()
EnumSet<Size> sizes1 = EnumSet.allOf(Size.class);
// Creating an EnumSet using noneOf()
EnumSet<Size> sizes2 = EnumSet.noneOf(Size.class);
// Using add method
sizes2.add(Size.MEDIUM);
System.out.println("EnumSet Using add(): " + sizes2);
// Using addAll() method
sizes2.addAll(sizes1);
System.out.println("EnumSet Using addAll(): " + sizes2);
}
}
SAMER SAEID