1. public static void main(String[] args) throws Exception{
    2. int[] nums = new int[]{1,2,3,4,5,6,7,8,9,10,11};
    3. System.arraycopy(nums, 5, nums, 0,
    4. nums.length - 5);
    5. System.out.println(Arrays.toString(nums));
    6. }

    输出:[6, 7, 8, 9, 10, 11, 7, 8, 9, 10, 11]

    注:由于仅拷贝第五位到最后一位,故而只有前面的元素改变,后边的元素没有变化,如果只想保留拷贝部分,也可以用以下方法:

    1. public static void main(String[] args) throws Exception{
    2. int[] nums = new int[]{1,2,3,4,5,6,7,8,9,10,11};
    3. int[] copyNums = new int[6];
    4. System.arraycopy(nums, 5, copyNums, 0,
    5. copyNums.length);
    6. System.out.println(Arrays.toString(copyNums));
    7. }

    输出:[6, 7, 8, 9, 10, 11]