I have a large 2D array:
int[][] matrix = new int[10000][1000];
The program needs to use frequently:
Arrays.fill(int[] a, int fromIndex, int toIndex, int val);
But sometimes it need to fill a row, and sometimes a column. For example, I can fill a row 200 by 1 from 10 to the end:
Arrays.fill(matrix[200], 10, 1000, 1);
But how to fill a column without for()?
Is there a data structure that allows to perform both operation with speed, comparable to Arrays.fill() ?
matrix[0][0],matrix[1][0], etc....Arrays.fill()just happens to hide the loop from you.