package com.cpic.test;
/**
* 关于枚举类型自定义属性
* */
public enum Provious {

ANHUI("皖", 1),BAIJING("京" ,2);

private String value;
private int key;

private Provious(String value, int key) {
this.value = value;
this.key = key;
}

public String getValue() {
return value;
}

public void setValue(String value) {
this.value = value;
}

public int getKey() {
return key;
}

public void setKey(int key) {
this.key = key;
}
}

 

测试:

package com.cpic.test;

public class Test {

public static void main(String[] args) {

System.out.println(""+Provious.ANHUI.getValue());
System.out.println(""+Provious.BAIJING.getKey());
System.out.println(""+Provious.ANHUI.getValue());


}

}

输出:


2

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-08-30
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-17
  • 2021-06-18
猜你喜欢
  • 2022-01-14
  • 2022-12-23
  • 2021-09-27
  • 2021-12-29
相关资源
相似解决方案