Lesson 13 of 34
Nested Loops: Star Patterns
10 min 30 XP
You can put one loop inside another. The outer loop controls the rows and the inner loop prints each row's characters. Pattern questions are very common in campus interviews.
Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Example: edit me and press Run
Output Loading Java (first time takes a few seconds)
Press Run to see the result here.Write a small table of how many spaces and stars each row has. The loop limits become obvious.