Specifications

Sun Services
Java™ Programming Language
Module 5, slide 15 of 15
Copyright 2005 Sun Microsystems, Inc. All Rights Reserved. Sun Services, Revision F
Copying Arrays
The System.arraycopy() method to copy arrays is:
1 //original array
2 int[] myArray = { 1, 2, 3, 4, 5, 6 };
3
4 // new larger array
5 int[] hold = { 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 };
6
7 // copy all of the myArray array to the hold
8 // array, starting with the 0th index
9 System.arraycopy(myArray, 0, hold, 0, myArray.length);