zoukankan      html  css  js  c++  java
  • 关于Java 枚举类型的自定义属性

    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

  • 相关阅读:
    旅行
    赛道修建
    逃学的小孩
    hdu4035_概率dp
    hdu4405_概率dp
    poj2096_概率dp
    poj3420_找规律+矩阵快速幂
    poj2411_状压dp
    poj3744_矩阵快速幂
    hdu5720_贪心
  • 原文地址:https://www.cnblogs.com/jpfss/p/8990574.html
Copyright © 2011-2022 走看看