1.开发中如何使用枚举,一般在开发中使用消息提示。枚举可以继承,实现接口等。
public enum Result {
SUCCESS(1,"201 ok") {
@Override
void doCallBack(String msg) {
System.out.println("201 success process!!!" + "\t" + msg);
}
},
ERROR(2,"501 server error") {
@Override
void doCallBack(String msg) {
System.out.println("server error process !!!" + "\t" + msg);
}
},
FAIRL(3,"javascript error") {
@Override
void doCallBack(String msg) {
System.out.println("javascript error process!!!" + "\t" + msg);
}
}; private int code;
private String msg;
abstract void doCallBack(String msg); Result(int code,String msg){
this.code = code;
this.msg = msg;
} public static void main(String[] args) {
Result v = Result.ERROR;
v.doCallBack(v.msg);
}
}