I am trying to find the index of each object in my array.
public class MonsterTest {
public static void main(String[] args) {
// TODO Auto-generated method stub
Monster [] ma = new Monster[3];
ma[0] = new Vampire();
ma[1] = new Dragon();
ma[2] = new Monster();
for(int x = 0; x < 3; x++) {
System.out.println(ma[x].getClass());
System.out.println(java.util.Arrays.asList(ma[x]).indexOf(x));
ma[x].frighten(x);
}
}
}
Am I using the java.util.Arrays.asList(ARRAY).indexOf(element) method here correct? (Well I am obviously not because the output is incorrect.
Arrays.asList(..)do? What doesindexOf(..)do? (Go see.)