public class Demo04 {标签:arrays,反转,int,length,static,result,数组,public From: https://www.cnblogs.com/123456dh/p/17095106.html
public static void main(String[] args) {
int[] arrays={1,2,3,4,5};
print(reverse(arrays));
}
//反转数组
public static int[] reverse(int[] arrays){
int[] result=new int[arrays.length];
for (int i = 0,j=arrays.length-1; i < arrays.length ; i++,j--) {
result[j]=arrays[i];
}
return result;
}
//打印数组元素
public static void print(int[] arrays){
for (int i = 0; i <arrays.length ; i++) {
System.out.println(arrays[i]);
}
}
}