A nested loop is a loop inside another loop. The inner loop runs to completion for every single iteration of the outer loop.
for (int row = 1; row <= 3; row++) {
for (int col = 1; col <= 3; col++) {
System.out.print(col + " ");
}
System.out.println();
}
Output:
1 2 3
1 2 3
1 2 3
The outer loop runs times. Each time it runs, the inner loop runs times. That's total print calls. If the outer loop ran times and the inner loop ran times, you'd get executions of the inner body.
This is why nested loops can be slow. Doubling n doesn't double the work. It quadruples it.