枚举
// 枚举的使用
public class Demo_Template {
public static void main(String[] args) {
System.out.println(Week.MON);
System.out.println(Week.MON.toString());
}
}
enum Week {
MON("星期一"), TUE("星期二"), WED("星期三");
private String name;
private Week(String Name) {
name = Name;
}
public String toString() {
return name;
}
}
// 枚举的遍历
public class Demo_Template {
public static void main(String[] args) {
Week[] arr = Week.values();
for (Week week : arr) {
System.out.println(week);
}
}
}
enum Week {
MON("星期一"), TUE("星期二"), WED("星期三");
private String name;
private Week(String Name) {
name = Name;
}
public String toString() {
return name;
}
}