import java.util.*;
class Example{
public static void main(String[] args){
Random ran = new Random();
int[] array1 = new int[10]; //创建数组
int[] array2 = new int[10]; //创建逆序数组
int index1 = 0; //数组的下标
int index2 = array2.length-1; //逆序数组的下标
for(int x=0;x<array1.length;x++){
int num = ran.nextInt(10);
array1[index1] = num;
array2[index2] = array1[index1];
index1++;
index2--;
}
System.out.println("array1 = "+Arrays.toString(array1));
System.out.println("array2 = "+Arrays.toString(array2));
}
} |