title: Iterating over ResultSet and adding its value in an ArrayList
body: <p>I am iterating over an <code>ResultSet</code> and trying to copy its values in an <code>ArrayList</code>.
  The problem is that its traversing only once. But using <code>resultset.getString("Col 1")</code> to <code>resultset.getString('Col n")</code> is showing all entries of all columns.
  Below is the code snippet -</p>
  
  <pre><code>ResultSet resultset = null;
  ArrayList&lt;String&gt; arrayList = new ArrayList&lt;String&gt;(); 
  int i = 1;
  while (resultset.next()) {              
      arrayList.add(resultset.getString(i++));
      System.out.println(resultset.getString("Col 1"));
      System.out.println(resultset.getString("Col 2"));
      System.out.println(resultset.getString("Col n"));
  }
  </code></pre>
  
  <p>The only value of <code>ResultSet</code> getting copied into <code>ArrayList</code> is for column 1. And then while exits.
  But I can see the value of all columns.
  Why?</p>