What will the following code output?
for (int i = 1; i <= 3; i++) {
for (int j = i; j <= 3; j++) {
System.out.print(j + " ");
}
}
The inner loop starts from the value of i
, so in the first iteration, j
goes from 1 to 3, then from 2 to 3, and finally only 3.
The inner loop starts from the value of i
, so in the first iteration, j
goes from 1 to 3, then from 2 to 3, and finally only 3.