java enum的一种写法记录
public enum TestEnum { provider { @Override public void provide() { this.name = "hjzgg"; } }; public String name; public abstract void provide(); public static void main(String[] args) { TestEnum testEnum = Enum.valueOf(TestEnum.class, "provider"); testEnum.provide(); System.out.println(testEnum.name); TestEnum testEnum2 = TestEnum.provider; testEnum2.provide(); System.out.println(testEnum2.name); } }
本文来自博客园,作者:hjzqyx,转载请注明原文链接:https://www.cnblogs.com/hujunzheng/p/7551425.html