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

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">