package number; public class Number { public static void main(String[] args) { int[] arr={5,2,1,0,3,6,8,7}; int[] index={2,0,3,5,1,3,5,3,6,5,7}; String tel=""; for(int i:index){ System.out.println(i); System.out.println("xx"+arr[i]); } System.out.println(tel); } }
结果
2 xx1 0 xx5 3 xx0 5 xx6 1 xx2 3 xx0 5 xx6 3 xx0 6 xx8 5 xx6 7 xx7
for(int i:index){ System.out.println(i);}表示逐个输出集合元素