Java array elements to achieve reversal

package com.fgy.demo;

/**
 * Reverse array element
 */
public class demo05 {
    public static void main(String[] args) {
        int[] arr = {10, 20, 30, 40, 50};
        Of System.out.print ( "before reverse Array:" );
         for ( int I = 0; I <arr.length; I ++ ) {
            System.out.print(arr[i] + "   ");
        }

        System.out.println();
        for(int min = 0, max = arr.length - 1; min < max; min++, max--) {
            int temp = arr[min];
            arr[min] = arr[max];
            arr[max] = temp;
        }

        Of System.out.print ( "array after inversion:" );
         for ( int I = 0; I <arr.length; I ++ ) {
            System.out.print(arr[i] + "   ");
        }
    }
}

Guess you like

Origin www.cnblogs.com/roadlandscape/p/12057073.html