已有数组保
int arr[] = new int[]{1, 2, 3, 4, 5, 6};
for (int i = 0; i <arr.length/2; i++) {
int temp=arr[i];
arr[i]=arr[arr.length-i-1];
arr[arr.length-i-1]=temp;
}
for (int i = 0; i <arr.length; i++) {
System.out.print(" "+arr[i]);
}
System.out.println();
存1,3,5,2,4,6 控制台输出:6 4 2 5 3 1