How to copy an array

To copy the contents of one array into another array you can use the static method arraycopy() of the System class.
The method takes five parameters: source, source start position, destination, destination start position and finally the length of the data to be copied.
In this example we create an array of integers with ten values and then use the arraycopy() method to copy the contents to another array.

The output of the code will be (as you might have guessed):

Search for more Java info on this site here:
Custom Search

Please type any questions here.