数组的倒置

直接贴代码

 1 package com.cz.test;
 2 
 3 public class ArrayRevese {
 4 
 5     //数组倒置方法
 6     public static int [] getR(int arr[]){
 7         //首先定义一个新数组
 8         int resver[] =new int[arr.length];
 9         //拿出第一个值,把他放在新数组的最后一个位置
10         for(int i=0;i<arr.length;i++){
11             resver[arr.length-1-i]=arr[i];
12         }
13         
14         return resver;
15     }
16     
17     
18     public static void main(String[] args) {
19         int [] s={1,2,3,4};
20         int ss[]=getR(s);
21         for (int i : ss) {
22             System.out.println(i);
23         }
24     }
25 }
原文地址:https://www.cnblogs.com/javaweb2/p/6241103.html