//數組逆序

 1 class Demo1 {
 2     public static void main(String[] args) {
 3         int[] arr = {1, 2, 3, 4, 5, 6};
 4         for (int i=0;i<arr.length/2;i++){
 5             int temp = arr[i];
 6             arr[i]  = arr[arr.length-(i+1)];
 7             arr[arr.length-(i+1)] = temp;
 8 
 9         }
10         System.out.println(Arrays.toString(arr));
11     }
12 }
相關文章
相關標籤/搜索