<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Aviral Pathak</title>
    <description>The latest articles on DEV Community by Aviral Pathak (@aviral_pathak_cbda60e8370).</description>
    <link>https://dev.to/aviral_pathak_cbda60e8370</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3592706%2Fdcf0b0c0-8cc1-4a15-93f6-01f428ddadb1.gif</url>
      <title>DEV Community: Aviral Pathak</title>
      <link>https://dev.to/aviral_pathak_cbda60e8370</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/aviral_pathak_cbda60e8370"/>
    <language>en</language>
    <item>
      <title>Day 1 of #LearnInPublic Java Patterns</title>
      <dc:creator>Aviral Pathak</dc:creator>
      <pubDate>Sat, 01 Nov 2025 21:10:27 +0000</pubDate>
      <link>https://dev.to/aviral_pathak_cbda60e8370/day-1-of-learninpublic-java-patterns-hpi</link>
      <guid>https://dev.to/aviral_pathak_cbda60e8370/day-1-of-learninpublic-java-patterns-hpi</guid>
      <description>&lt;p&gt;🎯 Topic: Rectangular Star Pattern&lt;br&gt;
👨‍💻 Concepts Used: Nested Loops&lt;/p&gt;

&lt;p&gt;I learned how to use nested for loops in Java to print shapes.&lt;br&gt;
Outer loop → controls rows&lt;br&gt;
Inner loop → controls columns&lt;/p&gt;

&lt;p&gt;Here’s my output for N = 4 👇&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* * * *
* * * *
* * * *
* * * *
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It looks simple — but understanding how loops nest inside each other really builds logic skills for future problems.&lt;/p&gt;

&lt;p&gt;💡 Takeaway: Pattern questions are the best way to train your brain for logical thinking.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Main {
   static void pattern1(int N)
{
    // This is the outer loop which will loop for the rows.
    for (int i = 0; i &amp;lt; 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 &amp;lt; N; j++)
        {
            System.out.print("* ");
        }

         // As soon as N stars are printed, we move to the
        // next row and give a line break otherwise all stars
        // would get printed in 1 line.
        System.out.println();
    }
}

    public static void main(String[] args) {

        // Here, we have taken the value of N as 5.
        // We can also take input from the user.
        int N = 5;
        pattern1(N);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Approach: &lt;br&gt;
There are 4 general rules for solving a pattern-based question: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We always use nested loops for printing the patterns. For the outer loop, we count the number of lines/rows and loop for them.&lt;/li&gt;
&lt;li&gt;Next, for the inner loop, we focus on the number of columns and somehow connect them to the rows by forming a logic such that for each row we get the required number of columns to be printed.&lt;/li&gt;
&lt;li&gt;We print the ‘*’ inside the inner loop.&lt;/li&gt;
&lt;li&gt;Observe symmetry in the pattern or check if a pattern is a combination of two or more similar patterns.&lt;/li&gt;
&lt;li&gt;In this particular problem, we run the outer loop for N times since we have N rows to be printed, the inner loop also runs for N times as we have to print N stars in each row. This way we get a rectangular star pattern (square) with an equal number of rows and columns
.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>beginners</category>
      <category>tutorial</category>
      <category>java</category>
    </item>
  </channel>
</rss>
