How do I fill arrays in Java?

Check out the Arrays.fill methods.

int[] array = new int[4];
Arrays.fill(array, 1); // [1, 1, 1, 1]

Leave a Comment