1.无参数

public enum TYPE {
        INSERT, UPDATE, DELETE;
    }

 

2.带参数:

public enum Topics {
    
        OK(0, "成功"),
        xx(100, "错误A"),
        yyy(200, "错误B");

          Topics(int number, String description) {
                this.code = number;
                this.description = description;
         }
          
        private int code;
        private String description;
        public int getCode() {
            return code;
        }
        public String getDescription() {
            return description;
        }
    
    
}

 

posted on 2020-04-08 17:11  lshan  阅读(108)  评论(0编辑  收藏  举报