🎯 Topic: Rectangular Star Pattern 👨‍💻 Concepts Used: Nested Loops

I learned how to use nested for loops in Java to print shapes. Outer loop → controls rows Inner loop → controls columns

Here’s my output for N = 4 👇

* * * *
* * * *
* * * *
* * * *

It looks simple — but understanding how loops nest inside each other really builds logic skills for future problems.

💡 Takeaway: Pattern questions are the best way to train your brain for logical thinking.

class Main {
static void pattern1(int N)
{
// This is the outer loop which will loop for the rows.
for (int i = 0; i < N; i++)
{
// This is the inner loop which here, loops for the columns
// as we have to print a rectangular pattern.
for (int j = 0; j < N; j++)
{
System.out.print("* ");
}

// As soon as N stars are printed...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help