Arrays.copyOf() in Java


Use Arrays.copyOf() to make a copy of an array. It’s useful for preserving original data.

Source Code

int[] original = {1, 2, 3, 4, 5};
int[] copied = Arrays.copyOf(original, original.length);
System.out.println("Copied Array: " + Arrays.toString(copied));
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments