That's because data2 has length 1000, each of which has an array of length 200. Not the other way around. This works: double[200][1000] data2; void main() { for(int i = 0; i < 1000; i++) { for(int j = 0; j < 200; j++) { data2[i][j] = 4.0; } } }