Example 1 — Grow a row with a char loop
The outer char is the last letter on the row. The inner loop restarts at 'A'.
public class CharTriangle {
public static void main(String[] args) {
for (char end = 'A'; end <= 'E'; end++) {
for (char letter = 'A'; letter <= end; letter++)
System.out.print(letter);
System.out.println();
}
}
} How It Works
endruns from'A'to'E', one row per letter.- The inner loop prints
'A'throughend, so the row is A…end. printstays on the line;printlnstarts the next row.

