public enum Animal{
DOG,CAT;
}
javac转class class用jad反编译
// Decompiled by Jad v1.5.8g. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://www.kpdus.com/jad.html
// Decompiler options: packimports(3)
// Source File Name: Animal.java
public final class Animal extends Enum
{
public static Animal[] values()
{
return (Animal[])$VALUES.clone();
}
public static Animal valueOf(String s)
{
return (Animal)Enum.valueOf(Animal, s);
}
private Animal(String s, int i)
{
super(s, i);
}
public static final Animal DOG;
public static final Animal CAT;
private static final Animal $VALUES[];
static
{
DOG = new Animal("DOG", 0);
CAT = new Animal("CAT", 1);
$VALUES = (new Animal[] {
DOG, CAT
});
}
}
可以看到枚举相比较两个int常量是比较占内存的
动态代理
https://www.cnblogs.com/flyoung2008/archive/2013/08/11/3251148.html