- enum Week {
- MON("星期一",1),TUE("星期二",2),WEN("星期三",3),THI("星期四",4),
- FRI("星期五",5),SAT("星期六",7),SUN("星期日",8);
- //成员变量
- private String Name;
- private int index;
-
- //构造方法
- private Week(String Name,int index) {
- this.Name = Name;
- this.index = index;
- }
-
- // get set 方法
- 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;
- }
-
- //星期的中文格式
- public String toLocaleString() {
- for (Week w : Week.values())
- {
- if (w.getIndex() == index)
- {
- System.out.println(w.Name);
- }
- }
- return null;
- }
- }
- public class Test3{
- public static void main(String[] args){
- Week.toLocaleString();
- }
- }
复制代码 这个程序只剩下一点小小的问题了,怎么解决?
|