码迷,mamicode.com
首页 > 编程语言 > 详细

Java数组逆序存储

时间:2017-09-12 10:03:37      阅读:277      评论:0      收藏:0      [点我收藏+]

标签:pack   public   static   for   数组   util   logs   str   eth   

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));
    }
}

 

Java数组逆序存储

标签:pack   public   static   for   数组   util   logs   str   eth   

原文地址:http://www.cnblogs.com/qiushuiblog/p/7508289.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!