How do I fill arrays in Java?

I know how to do it normally, but I could swear that you could fill out out like a[0] = {0,0,0,0}; How do you do it that way? I did try Google, but I didn't get anything helpful.


Check out the Arrays.fill methods.

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

You can also do it as part of the declaration:

int[] a = new int[] {0, 0, 0, 0};