目录标题
一、枚举类
package enum_;
/**
* @author 15594
*
* 枚举类
*/
public enum Week {
星期一("星期一",1), 星期二("星期二",2),星期三("星期三",3),星期四("星期四",4),星期五("星期五",5),星期六("星期六",6),星期七("星期七",7);
private String name;
private int index;
Week() {
}
Week(String name, int index) {
this.name = name;
this.index = index;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getIndex() {
return index;
}
public void setIndex(int index) {
this.index = index;
}
}
enum Week1 {
A,B,C,D,E,F,G;
}
class Test{
public static void main(String[] args) {
System.out.println(Week1.B);
System.out.println(Week.星期三);
System.out.println(Week.星期一.getName());
System.out.println(Week.星期七.getIndex());
}
}