????Set??Java????????????????????????洢????????????????????????????????????????????????????????????????????????????е??????????????????????????????????????????????á?EnumSet??????enum??????????????????????÷???
?????·??????????????EnumSet???????????????????????ж????????????EnumSet???add()??????????????EnumSet???remove()??????????????EnumSet???complementOf()????????????????????EnumSet???range()????????????Χ??????
???????????£?

 

Weeks.java:
packagecn.edu.xidian.crytoll;
publicenumWeeks{
MONDAY??TUESDAY??WEDNESDAY??THURSDAY??FRIDAY??SATURADAY??SUNDAY
}
EnumSetTest.java:
packagecn.edu.xidian.crytoll;
importstaticcn.edu.xidian.crytoll.Weeks.MONDAY;
importstaticcn.edu.xidian.crytoll.Weeks.THURSDAY;
importjava.util.EnumSet;
publicclassEnumSetTest{
publicstaticvoidmain(String[]args){
EnumSetweek=EnumSet.noneOf(Weeks.class);
week.add(MONDAY);
System.out.println("EnumSet?е?????"+week);
week.remove(MONDAY);
System.out.println("EnumSet?е?????"+week);
week.addAll(EnumSet.complementOf(week));
System.out.println("EnumSet?е?????"+week);
week.removeAll(EnumSet.range(MONDAY??THURSDAY));
System.out.println("EnumSet?е?????"+week);
}
}