I want to create an array of size n with the same value at every index in the array. What\'s the best way to do this in Java?
n
For example, if n
Or you can do it in the low level way. Make an array with n elements and iterate through all the element where the same element is put in.
int[] array = new int[n]; for (int i = 0; i < n; i++) { array[i] = 5; }