定义一个Enum.class :
package com.dvision;
public enum SeasonEnum {
Spring,summer,fall,winter
}
测试枚举类:
package com.dvision;
import java.util.Scanner;
public class EnumImpl {
public void judge(SeasonEnum s){
switch (s) {
case Spring:
System.out.println("hello Spring");
break;
case summer:
System.out.println("hello Summer");
break;
case fall:
System.out.println("hello Fall");
break;
case winter:
System.out.println("hello Winter");
break;
default:
break;
}
}
public static String readConsole(String p){
Scanner scanner = new Scanner(System.in);
System.out.println(p);
return scanner.nextLine();
}
public static void main(String[] args) {
for (SeasonEnum s : SeasonEnum.values()) {
System.out.println(s);
}
System.out.println(SeasonEnum.Spring);
EnumImpl e = new EnumImpl();
String str = readConsole("要输入的字符串:");
System.out.println(str);
}
}