1 package com.wzbc.test; 2 3 public enum session { 4 5 6 //自定义的枚举必须在类的最前面 7 //枚举之间需要以逗号间隔 8 SUCCESS("成功 ",123), 9 FAIL("shibai ",1124); 10 11 12 //成员变量必须在枚举之后 13 private String name; 14 private int code; 15 16 17 //构造器必须是私有 18 private session(String name, int code) { 19 this.name = name; 20 this.code = code; 21 } 22 23 public String getName() { 24 return name; 25 } 26 27 public int getCode() { 28 return code; 29 } 30 31 @Override 32 public String toString() { 33 return "session{" + 34 "name='" + name + '\'' + 35 ", code=" + code + 36 '}'; 37 } 38 }
标签:code,name,int,枚举,public,String From: https://www.cnblogs.com/lipengtao/p/17082363.html