public class TestArrays {
public static void main(String[] args) {
String[] islands = new String[8];
islands[0] = "Бермуды";
islands[1] = "Фиджи";
islands[2] = "Азорские острова";
islands[3] = "Косумель";
islands[4] = "Четыре";
islands[5] = "Пять";
islands[6] = "Шесть";
islands[7] = "Семь";
int[] index = new int[8];
index[0] = 1;
index[1] = 3;
index[2] = 0;
index[3] = 2;
index[4] = 5;
index[5] = 7;
index[6] = 4;
index[7] = 6;
int ref;
int y = 0;
while (y < 8){
ref = index[y];
System.out.print("острова = ");
System.out.println(islands[ref]);
y = y + 1;
}
}
}
public class TestArrays {
public static void main(String[] args) {
String[] islands = new String[]{
"Бермуды",
"Фиджи",
"Азорские острова",
"Косумель",
"Четыре",
"Пять",
"Шесть",
"Семь"
};
int[] index = new int[]{
1, 3, 0, 2, 5, 7, 4, 6
};
for (int i = 0; i < index.length; i++) {
int ref = index[i];
System.out.println("острова = " + islands[ref]);
}
}
}