// 数组复制
int[] arrays = new int[]{1,3,5,6,8,9,4,3,4,5};
int[] newarrays = new int[]{};
newarrays = Arrays.copyOf(arrays, 5);
int[] newarrays2 = Arrays.copyOf(arrays, 15);
int[] newarrays3 = Arrays.copyOfRange(arrays, 2,4);
for(int e:newarrays){
System.out.print(e+",");
}
System.out.print("\n");
for(int e:newarrays2){
System.out.print(e+",");
}
System.out.print("\n");
for(int e:newarrays3){
System.out.print(e+",");
}
运行效果如下:
1,3,5,6,8,
1,3,5,6,8,9,4,3,4,5,0,0,0,0,0,
5,6,