To make the above code more simpler, we can replace the inner loop with System.arraycopy() as in the case of a single-dimensional array. For example,
Output:
Here, we can see that we get the same output by replacing the inner for loop with the arraycopy() method.