In Java, the System class contains a method named arraycopy() to copy arrays. This method is a better approach to copy arrays than the above two. The arraycopy() method allows you to copy a specified portion of the source array to the destination array. For example,
Here,
Let's take an example:
Output for the above program can be
In the above example, we have used the arraycopy() method,
As you can see, the default initial value of elements of an int type array is 0.