首页 > 代码库 > Java中自己实现枚举

Java中自己实现枚举

public class MyEnum {

 

private final String name;

 

public  static final MyEnum red = new MyEnum("红色");

public  static final MyEnum green = new MyEnum("绿色");

public  static final MyEnum black = new MyEnum("黑色");

public  static final MyEnum yellow = new MyEnum("黄色"); 

 

public MyEnum(String name){

 

this.name = name;

}

 

public String getName(){

return this.name;

}

 

 

 

 

 

 

}

Java中自己实现枚举