需求:数组内部进行反转;eg:[11,22,33]反转成[33,22,11]
代码实现:
public class Test1 {
//学习数组之 数组内部进行反转
// {10,20,30,40,50} 反转成 {50,40,30,20,10}
//有点类似于数据结构里面的排序
public static void main(String[] args) {
int [] arr1 = {10,20,30,40,50};
for (int i = 0 ,j = arr1.length-1; i < j; i++,j--)
{
int temp= 0;
temp=arr1[j];
arr1[j] = arr1[i];
arr1[i] = temp;
}
for (int i = 0; i < arr1.length; i++) {
System.out.print(arr1[i] +" ");
}
}
}