/**
数组逆序:
即头尾互换
*/
public class ArrayConvert{
public static void main(String[] args){
int[] arr = {9, -1, 10, 100, 1, 20, -12};
for(int i = 0; i <= arr.length / 2; i++){
int temp = arr[i];
arr[i] = arr[arr.length - 1 - i];
arr[arr.length - 1 - i] = temp;
}
for(int i = 0; i < arr.length; i++){
System.out.println(arr[i]);
}
}
}
|
|