标签:
package com.bobo.www.cxf.impl; public enum Traffic { Red(1), Green(2), Yellow(3);//必须最前面 private int flag = 0; private Traffic() { System.out.println("init"); } private Traffic(int flag) { this.flag = flag; } public String toString() { return String.valueOf(flag); }; }
public class doit { public static void main(String[] args) { Traffic t1 = Traffic.Green; for(Traffic t : Traffic.values()){ System.out.println(t); } System.out.println(); } }
标签:
原文地址:http://www.cnblogs.com/whatlonelytear/p/4499541.html