public class test {
static int install_update=0;
static int framework_install=0;
static int framework_install_recovery=0;
static int uninstall=0;
static int framework_uninstall_recovery=0;
public static void main(String [] args){
System.out.println("hello word");
final int TYPE_COUNT = Type.values().length;
System.out.println(TYPE_COUNT);
}
public enum Type {
INSTALLER( install_update, framework_install,framework_install_recovery),
UNINSTALLER( uninstall, uninstall, framework_uninstall_recovery);
public final int title;
public final int text_flash;
public final int text_flash_recovery;
Type( int title, int text_flash, int text_flash_recovery) {
this.title = title;
this.text_flash = text_flash;
this.text_flash_recovery = text_flash_recovery;
}
}
}
请问这里的
INSTALLER( install_update, framework_install,framework_install_recovery),
UNINSTALLER( uninstall, uninstall, framework_uninstall_recovery);
这是“INSTALLER“ “UNINSTALLER”里面什么数据结构呢?
枚举
比较神奇,每个枚举项
都是当前枚举类的实例
。看你的代码,分下段:
我们把这个枚举类改造一下,不使用
enum
关键字,使用class
:这就是一个普普通通的类,枚举项什么意思呢,再看:
这样简单改造,就可以很清晰了。