I have this array exercise. I want to understand how things work, if someone can
- we have the object array of type int called
indexwith 4 elements - we have the object array of type String called
islandswith 4 elements
I don't understand how things are passing to each other, I need a good explanation.
class Dog {
public static void main(String [] args) {
int [] index = new int[4];
index[0] = 1;
index[1] = 3;
index[2] = 0;
index[3] = 2;
String [] islands = new String[4];
islands[0] = "Bermuda";
islands[1] = "Fiji";
islands[2] = "Azores";
islands[3] = "Cozumel";
int y = 0;
int ref;
while (y < 4) {
ref = index[y];
System.out.print("island = ");
System.out.println(islands[ref]);
y ++;
}
}