a- package review;
- public class EnumDemo {
- /**
- * @param args
- */
- public static void main(String[] args) {
- WeekDay w = WeekDay.SUN;
- WeekDay w1 = WeekDay.MON;
- w1.show();
- }
- //枚举也相当于一个类,其中也可以定义构造方法,成员变量,普通方法和抽象方法
- //枚举元素必须放在枚举体中最开始位置
- public enum WeekDay{
- SUN,MON(46);
- private WeekDay(){
- System.out.println("hah");
- }
- private WeekDay(int i){
- System.out.println("enum "+i);
- }
- public void show(){
- System.out.println("show");
- }
- }
- }
复制代码
|
|