首页 > 代码库 > java.lang.ArrayIndexOutOfBoundsException
java.lang.ArrayIndexOutOfBoundsException
数组越界
public class TestArrayCopy1
{
public static void main(String[] args)
{
int ia [] = new int[]{1, 2, 3, 4, 5};
int ib [] = new int[]{9, 8, 7, 6, 5, 4, 3};
System.arraycopy(ia, 0, ib, ib.length-ia.length, ia.length);
//复制源数组中从下标0开始的ia.length个元素到目的数组,从下标ib.length-ia.length的位置开始存储
for(int i=0; i<ia.length; i++)
{
System.out.print(ia[i]);
}
System.out.println();
for(int i=0; i<ib.length; i++)
{
System.out.print(ib[i]);
}
System.out.println();
}
}
~
java.lang.ArrayIndexOutOfBoundsException