System.arraycopy用法

package wzs.sort;

import java.util.Arrays;

//public static void arraycopy(Object src,int srcPos,Object dest,int destPos,int length)
//src - 源数组。
//srcPos - 源数组中的起始位置。
//dest - 目标数组。
//destPos - 目标数据中的起始位置。
//length - 要复制的数组元素的数量。
public class Test_013
{

    public static void main(String[] args)
    {
        int[] intArray =
        {
                0, 1, 2, 3, 4, 5
        };
        System.out.println(Arrays.toString(intArray));// [0, 1, 2, 3, 4, 5]

        System.arraycopy(intArray, 0, intArray, 2, 2);
        System.out.println(Arrays.toString(intArray));// [0, 1, 0, 1, 4, 5]

        int[] intArray2 =
        {
                0, 1, 2, 3, 4, 5, 6, 7, 8, 9
        };
        System.arraycopy(intArray, 2, intArray2, 4, 3);
        System.out.println(Arrays.toString(intArray2));// [0, 1, 2, 3, 0, 1, 4, 7, 8, 9]
    }
}


你可能感兴趣的:(System.arraycopy用法)