Prev Next

Java / Arrays

How to copy an array in Java?

We can create a copy of an array in two ways, the first one is manually by iterating over the array and the second one is by using the arrayCopy() method. Using the arrayCopy() method of the System class is the fastest way to copy an array and also allows us to copy a part of the array.

You may also copy array by using the Arrays.copyOf() method and using clone() method.

More Related questions...

Show more question and Answers...


Comments & Discussions