class things {
public static void main(String args[]) {
int [][] nothing;
nothing = new int [4][5];
int i,j,k = 0;
for(i=0;i<4;i++)
for(j=0;j<5;j++) {
nothing[i][j] = k;
k++;
}
// Display the 2-D array
for(i=0;i<4;i++) {
for(j=0;j<5;j++)
System.out.print(nothing[i][j] + " ");
System.out.println();
}
}
}
In the code given, { is in the second nested for loop of the first loop set but { is on the first line of loop the second loop set. So why and when to use {} in loops in Java. I mean I'm getting pretty different outputs when the {} are removed.