package array; public class ArrayDemo5 { public static void main(String[] args) { //反转数组 int[] arrays = {1,2,3,4,5}; printArrays(reverse(arrays)); } public static int[] reverse(int[] array){ int[] result = new int[array.length]; //反转 *** 作 for (int i = 0,j=result.length-1; i < array.length; i++,j--) { result[j] = array[i]; } return result; } public static void printArrays(int[] arrays){ for (int i = 0; i < arrays.length; i++) { System.out.println(arrays[i]); } } }
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)