Java 自定义枚举

Enum MyEnum{

  A(1),B(3),C(5),D(7);

  

  private int value = 1;

  private MyEnum(int value){

    this.value = value;  

  }

 

  public int value(){

    return this.value;

  }

}

public static void main(String[] argc){

  System.out.println(MyEnum.C.value());

}

posted @ 2012-11-07 22:46  如坐夕阳  Views(179)  Comments(0Edit  收藏  举报