title: Using nested while loop to print pyramid of stars
body: <p>I'm trying to print a pyramid of stars using nested while loops. I know I am able to achieve this using for loops but I want to do it with while loop instead. This is my code so far: </p>
  
  <pre><code>public class WhileNest
  {
      public static void main(String[]args)
      {
          int rows = 5, i = 1, j = 1;
  
          while(i &lt;= rows)
          {
              while(j &lt;= i)
              {
                  System.out.print("*");
                  j++;
  
              }
              System.out.print("\n");
              i++;
  
          }
      }
  }
  </code></pre>
  
  <p>The output has to be like this: </p>
  
  <pre><code>*
  **
  ***
  ****
  *****
  </code></pre>
  
  <p>But my output is this:</p>
  
  <pre><code>*
  *
  *
  *
  *
  </code></pre>
  
  <p>Any help is appreciated, thanks. </p>