Java数组逆序存储

package review01;

import java.util.Arrays;

public class review01 {
    public static void main(String[] args) {
    method();
    }

    private static void method() {
    // 数组逆序存储
    int[] arr = { 2, 0, 1, 6, 1, 2, 0, 7, 2, 0, 1, 2, 3, 3 };
    for (int s = 0, e = arr.length - 1; s < e; s++, e--) {
        int t = arr[s];
        arr[s] = arr[e];
        arr[e] = t;
    }
    System.out.println(Arrays.toString(arr));
    }
}

 

posted @ 2017-09-12 08:43  e3tB8Wz7  阅读(1325)  评论(0编辑  收藏  举报