//给定原数组,要求复制原数组中索引a到b的元素到新数组
public class FanfaShuzuCopy {
public static void main(String[] args) throws Exception {
int[] arr={1,2,3,4,6};
int[] arr2=copy(arr,1,4);
for(int i=0;i<arr2.length;i++){
System.out.println(arr2[i]);
}
}
public static int[] copy(int[] arr,int from,int to ){
int[] arr2=new int[to-from];
int index=0;
for(int i =from;i<to;i++){
arr2[index]=arr[i];
index++;
}
return arr2;
}
}