Array Copy in Java - GeeksforGeeks
Overview of above methods:
- Simply assigning reference is wrong
- Array can be copied by iterative over array and one by one assigning elements.
- We can avoid iteration over elements using clone() or System.arraycopy()
- clone() creates a new array of same size, but System.arraycopy() can be used to copy from a source range to a destination range.
- System.arraycopy() is faster than clone() as it uses Java Native Interface (Source : StackOverflow)
Read full article from Array Copy in Java - GeeksforGeeks
Hi,
ReplyDeleteThanks for sharing. Cheers
http://www.flowerbrackets.com/java-system-arraycopy-example/