Arrays.copyOf() creates a new array with a copy of the original's elements. You specify the new length:
int[] original = {10, 20, 30};
int[] copy = Arrays.copyOf(original, 5);
// copy is {10, 20, 30, 0, 0}
If the new length is larger, the extra slots get default values. If it is smaller, the copy is truncated. The original array stays unchanged.
Arrays.fill() sets every element of an array to the same value:
int[] arr = new int[5];
Arrays.fill(arr, -1);
// arr is {-1, -1, -1, -1, -1}
This is useful when you need to initialize an array to something other than . Without fill(), you would need a loop to write the same value into every slot.