Set
Train of Thought Analysis: You can use
The Code is as follows:
Weeks. java:
package cn.edu.xidian.crytoll;public enum Weeks {MONDAY, TUESDAY, WEDNESDAY, THURSDAY, FRIDAY, SATURADAY, SUNDAY}
EnumSetTest. java:
Package cn.edu. xidian. crytoll; import static cn.edu. xidian. crytoll. weeks. MONDAY; import static cn.edu. xidian. crytoll. weeks. THURSDAY; import java. util. enumSet; public class EnumSetTest {public static void main (String [] args) {EnumSet <Weeks> week = EnumSet. noneOf (Weeks. class); week. add (MONDAY); System. out. println ("element in EnumSet:" + week); week. remove (MONDAY); System. out. println ("element in EnumSet:" + week); week. addAll (EnumSet. complementOf (week); System. out. println ("element in EnumSet:" + week); week. removeAll (EnumSet. range (MONDAY, THURSDAY); System. out. println ("element in EnumSet:" + week );}}
Effect