package com.test; import java.util.Arrays; /** * 有数组a[n],用java代码将数组元素顺序颠倒 * @author * * 2018年1月26日下午8:29:24 */ public class ArrayReverse { public static void main(String[] args) { int[] arr = {1,5,2,0,7,73,23}; for (int i = 0; i < arr.length / 2; i++) { int tmp = arr[i]; arr[i] = arr[arr.length - 1 - i]; arr[arr.length - 1 - i] = tmp; } System.out.println(Arrays.toString(arr)); } }