Nested loops are loops inside a loop. They are useful for patterns, accessing elements in multi-dimensional arrays, etc.
Source Code
for (int i = 1; i <= 5; i++) {
for (int j = 1; j <= i; j++) {
System.out.print("* ");
}
System.out.println(); // Move to the next line
}