public class ArrayCopyTest
{
static byte[] array1 = {65,66,67,68,69,70,71,72,73,74};
static byte[] array2 = {77,77,77,77,77,77,77,77,77,77};
public static void main(String args[])
{
System.out.println("复制前两个数组的内容为:");
System.out.println("array1 = " + new String(array1));
System.out.println("array2 = " + new String(array2));
System.arraycopy(array1,0,array2,0,array1.length);
System.out.println("复制后两个数组的内容为:");
System.out.println("array1 = " + new String(array1));
System.out.println("array2 = " + new String(array2));
System.arraycopy(array1,0,array1,3,array1.length-4);
System.arraycopy(array2,1,array2,0,array2.length-1);
System.out.println("移动后两个数组的内容为:");
System.out.println("array1 = " + new String(array1));
System.out.println("array2 = " + new String(array2));
}
} |
|