//数组的复制与反转
package com.test;
public class ArrayDemo2 {
public static void main(String[] args) {
String[] arr=new String[]{"AA","BB","C","D","E","f"};
//数组的复制
String[] arr1=new String[arr.length];
for(int i=0;i<arr1.length;i++){
arr1[i]=arr[i];
System.out.print(arr1[i]+"\t");
}
//数组的反转
for(int i=0;i<arr.length/2;i++){
String temp=arr[i];
arr[i]=arr[arr.length-1-i];
arr[arr.length-1-i]=temp;
}
//遍历
for (int i=0;i<arr.length;i++){
System.out.print(arr[i]+"\t");
}
//方法2-数组的反转
System.out.println("方法2");
for(int i=0,j= arr.length-1;i<j;i++,j--){
String temp=arr[i];
arr[j]=arr[i];
arr[i]=temp;
}
for(int i=0;i<arr.length;i++){
System.out.print(arr[i]+"\t");
}
}
}