enum 的 name 是怎么传进去的呢

enum 的 name 是如何传进去的呢?enum 的 name 是如何传进去的呢?public enum Enum01 {NANOSECONDS(0), MIC

enum 的 name 是如何传进去的呢?
enum 的 name 是如何传进去的呢?

public enum Enum01 {
NANOSECONDS(0), MICROSECONDS(1), MILLISECONDS(2), SECONDS(3);

    /** the index of this unit */
    private final int index;

    /** Internal constructor */
    Enum01(int index) {
        this.index = index;
    }

}

Enum01 en = Enum01.MICROSECONDS;
l.info(en.name());

--------------------------
输出:
MICROSECONDS

enum 的 name 是如何传进去的呢?很有些奇怪。
不过,这样用起来很爽啊。


唔,刚才查了一下,可以参考一下这个。
http://www.iteye.com/topic/6556