Java程序片段重排:实现数组元素访问
public class TestArrays {
public static void main(String[] args) {
String[] islands = new String[4];
int[] index = new int[4];
int y = 0;
int ref;
islands[0] = 'Bermuda';
islands[1] = 'Fiji';
islands[2] = 'Azores';
islands[3] = 'Cozumel';
index[0] = 1;
index[1] = 3;
index[2] = 0;
index[3] = 2;
while (y < 4) {
ref = index[y];
System.out.println('island = ' + islands[ref]);
y = y + 1;
}
}
}
Output:
island = Fiji
island = Cozumel
island = Bermuda
island = Azores
AI 优化版
原文地址:https://www.cveoy.top/t/topic/pcf7 著作权归作者所有。请勿转载和采集!