Skip to content

Loops inside loops

Watch it run · 1 of 4

A tiny table

1public class Main {
2 public static void main(String[] args) {
3 for (int row = 1; row <= 2; row++) {
4 for (int col = 1; col <= 3; col++) {
5 System.out.print(row * col + " ");
6 }
7 System.out.println();
8 }
9 }
10}

Memory

int row

1

Output

(nothing yet)

line 3The outer loop starts: row 1.

step 1 of 7