package com.fqs.test; import java.util.Arrays; public class hello { public static void main(String[] args) { //交换数组头尾交换 //交换前 12345 //交换后 54321 int []arr={1,2,3,4,5}; int temp=arr[0]; for (int i = 0,j=arr.length-1; i <=j/2 ; i++,j--) { temp=arr[i]; arr[i]=arr[j]; arr[j]=temp; } System.out.println("交换后的数组:"+Arrays.toString(arr)); } }
标签:头尾,arr,int,交换,60,数组 From: https://www.cnblogs.com/haha1988/p/17461665.html