In the for each loop, the output is 6. However, I thought that the output would be 0 since, at least for one dimensional arrays, for each loops only traverse arrays. How is "g" being edited if "f" is only a local variable in the loop?
int[][] g = new int[7][7];
for(int[] f : g) {
for(int h = 0; h < f.length; h++)
f[h] = 6;
}
System.out.println(g[4][6]);