????3?????????????·??? + ????
??????????ó??????????????y?????????????????????????????IWeekConstants ????MON?????Mon????????????????????????塣????????????÷???????????????????
?????????????????????????????????????????дtoString???????????????????£?
package com.zcr.test;
enum ActionTypeEnum{
//?????????????????????????ι???????????????????????????????
//?????????????????????????????????????????????????????д????????????????????
????(1??"xiazai")??????(2??"fangwen");
int index;
String name;
private ActionTypeEnum(int index??String name){
this.index = index;
this.name = name;
}
public int getIndex()
{
return index;
}
public void setIndex(int index)
{
this.index = index;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
}
public class EnumTest
{
public static void main(String[] args)
{
ActionTypeEnum[] actionTypeEnums = ActionTypeEnum.values();
for(ActionTypeEnum actionTypeEnum : actionTypeEnums){
System.out.println("name=" + actionTypeEnum.getName());
System.out.println("index= " + actionTypeEnum.getIndex());
System.out.println("oridary=" + actionTypeEnum.ordinal());
System.out.println("this = " + actionTypeEnum);
System.out.println("???????"  + actionTypeEnum.valueOf("????"));
System.out.println("name()????= " + actionTypeEnum.name());
System.out.println("--------------????????------------------");
}
}
}
???????н????
????name=xiazai
????index= 1
????oridary=0
????this = ????
???????????????
????name()????= ????
????--------------????????------------------
????name=fangwen
????index= 2
????oridary=1
????this = ????
???????????????
????name()????= ????
????--------------????????------------------
????4?????
????????? enum ?????????????? class???????????????Щ???????????????????enum ??????? extends ???????????????? enum ???????? java.lang.Enum??java??????У??????????н???