取出Enum的所有值,直接看代码...
[quote]
public enum EnumFirst {A, B, C, D, F, INCOMPLETE}
EnumFirst ef[] = EnumFirst.values();[color=blue]//取出来的是EnumFirst实例数组[/color]
System.out.print("EnumFirst values are: ");
for (int i = 0; i <ef.length; i++) {
System.out.print(ef[i] + " ");[color=blue]//自动调用toString类型,输出字符串[/color]
}
[/quote]
输出结果:
[quote]
EnumFirst values are: A B C D F INCOMPLETE
[/quote]
Cool...
[quote]
public enum EnumFirst {A, B, C, D, F, INCOMPLETE}
EnumFirst ef[] = EnumFirst.values();[color=blue]//取出来的是EnumFirst实例数组[/color]
System.out.print("EnumFirst values are: ");
for (int i = 0; i <ef.length; i++) {
System.out.print(ef[i] + " ");[color=blue]//自动调用toString类型,输出字符串[/color]
}
[/quote]
输出结果:
[quote]
EnumFirst values are: A B C D F INCOMPLETE
[/quote]
Cool...