Java loop not looping when code is added to loop
<p>Im confused as when i add code inside a loop it stops the looping (effectivly ending after the first round).</p>

<p>Code which is working fine</p>

<pre><code>StringBuilder sb = new StringBuilder(4096);
  while ((rs.next())) {
  System.err.println(rs.getRow());
  sb.append(rs.getString(1)).append(",");
  }
writeToCell(sheet,"P",row.getRowNum()+1,sb.toString());
</code></pre>

<p>Code which doesnt loop</p>

<pre><code>StringBuilder sb = new StringBuilder(4096);
    while ((rs.next())) {
    System.err.println(rs.getRow());
    String p=rs.getString(1);
    ArrayList&lt;Parent&gt; pscore = new ArrayList();
    pscore.add(new Parent(p));
    String Score= getSegment(pscore);
    sb.append(p).append("(").append(Score).append("),");
    }
writeToCell(sheet,"P",row.getRowNum()+1,sb.toString());
</code></pre>

<p>I cant figure out why it would loop in the top version and not the bottom version. No errors are thrown </p>
