/*
本程序比较二个数组arr1=arr1 = {2,4,6,8,10};arr2 = {3,5,7,9,11,13,15,17};
的长度,然后用长度短的数组覆盖长度长的数组的前几项,再将覆盖后的数组中的
元素打印出来。
*/
class Test
{
public static void main(String[] args)
{
int [] arr1 = {2,4,6,8,10};
int [] arr2 = {3,5,7,9,11,13,15,17};
if (arr1.length<arr2.length)
{
System.arraycopy(arr1,0,arr2,0,arr1.length);
for (int i=0;i<arr2.length ;i++ )
{
System.out.print(arr2+" ");
}
}
else
{
System.arraycopy(arr2,0,arr1,0,arr2.length); //这两句话是什么意思??是怎么实现调用的啊????
for (int i=0;i<arr1.length ;i++ )
{
System.out.print(arr1+" ");
}
}
System.out.println("over!");
}
}
|