一、数组逆序方法:
逆序赋值,将数组的第一位移动到最后一位,第二位移动到倒数第二位......
例:将数组arr1 = {11, 22, 33, 44, 55, 66}逆序为数组arr2 = {66, 55, 44, 33, 22, 11}
二、Java源代码
public class ArrayAssign { public static void main(String[] args){ int[] arr1 = {11, 22, 33, 44, 55, 66}; int[] arr2 = new int[arr1.length]; for(int i = 0; i <arr1.length ;i++){ arr2[i] = arr1[arr1.length-i-1]; System.out.print(arr2[i]+"\t"); } } }
三、运行IDEA程序及结果