public class MyObj {
public static int[] NUM_LIVES;
public static void main(String[] args) {
NUM_LIVES[CatTypes.CAT_TABBY.ordinal()] = 9;
}
}
enum CatTypes {
CAT_TABBY, CAT_CALICO, CAT_ZOMBIE
}
ASKER
public class MyObj {
public static int[] NUM_LIVES;
public static void main(String[] args) {
NUM_LIVES[CatTypes.CAT_TABBY.ordinal()] = 9;
NUM_LIVES[CatTypes.CAT_CALICO.ordinal()] = 9;
NUM_LIVES[CatTypes.CAT_ZOMBIE.ordinal()] = 9;
}
}
enum CatTypes {
CAT_TABBY, CAT_CALICO, CAT_ZOMBIE
}
ASKER
public class MyObj {
static enum CatTypes {
CAT_TABBY, CAT_CALICO, CAT_ZOMBIE
}
public static int[] NUM_LIVES;
public static void main(String[] args) {
NUM_LIVES = new int[5];
NUM_LIVES[CatTypes.CAT_TABBY.ordinal()] = 9;
NUM_LIVES[CatTypes.CAT_CALICO.ordinal()] = 9;
NUM_LIVES[CatTypes.CAT_ZOMBIE.ordinal()] = 9;
System.out.println(CatTypes.CAT_TABBY.ordinal());
System.out.println(CatTypes.CAT_CALICO.ordinal());
}
}
0
1
Java is a platform-independent, object-oriented programming language and run-time environment, designed to have as few implementation dependencies as possible such that developers can write one set of code across all platforms using libraries. Most devices will not run Java natively, and require a run-time component to be installed in order to execute a Java program.
TRUSTED BY
http://download.oracle.com/javase/tutorial/java/javaOO/enum.html