enum EnumTests { 上传(1,"da"),下载(2,"dasdasd"); int index; String name; private EnumTests(int index, String name) { this.index = index; this.name = name; } public int getIndex() { return index; } public void setIndex(int index) { this.index = index; } public String getName() { return name; } public void setName(String name) { this.name = name; } } public class EnumService { public static void main(String[] args) { EnumTests[] s= EnumTests.values(); for (EnumTests e:s) { System.out.println(e.ordinal()); System.out.println(e.valueOf("下载")); System.out.println(e.name()); System.out.println(e.getIndex()); System.out.println(e.getName()); System.out.println("------------------------------------"); } } }
枚举
最新推荐文章于 2024-03-24 12:41:50 发布