枚举定义:
package com.example.md.signdemo.test; /** * <p> * 枚举常量类 * </p> * * @author 3hzpf * @since 2020-03-26 */ public enum EnumConstant { MONDAY(1), TUESDAY(2), WEDNESDAY(3), THURSDAY(4), FRIDAY(5), SATURDAY(6), SUNDAY(7); private int value; private EnumConstant(int value) { this.value = value; } public int get(){ return this.value; } }
实现:
public class EnumTest { public static void main(String[] args) { int value = EnumConstant.TUESDAY.get(); System.out.println("value:" + value); } }
控制台输出: