public class MyArrayReverse {
public static void main(String[] args){
int arr[]={11,22,33,44,55};
System.out.println("原数组为:");
for(int i=0;i<arr.length;i++)
System.out.println(arr[i]);
for(int i=0;i<=arr.length/2;i++){
int tmp=arr[i];
arr[i]=arr[arr.length-1-i];
arr[arr.length-1-i]=tmp;
}
System.out.println("翻转后数组为:");
for(int i=0;i<arr.length;i++)
System.out.println(arr[i]);
}
} |