title: Nested for-loop output
body: <p>I'm learning about Java loops and struggling to understand how an output was produced for a question regarding nested-for loops. </p>
  
  <p>The code is:</p>
  
  <pre><code>for(int count = 0; count &lt;=3; count++)
      for(int count2 = 0; count2 &lt; count; count2++)
          System.out.println(count2);
  </code></pre>
  
  <p>The output produced was:</p>
  
  <blockquote>
    <p>0<br>
    0<br>
    1<br>
    0<br>
    1<br>
    2  </p>
  </blockquote>
  
  <p>Can anyone please explain this as there isn't an explanation in the book like there usually is, thanks.</p>