title: How to collect all data from first column in table into array?
body: <p>I using netbeans 8.
  I need to loop to collect all employee ID from first column of jtable and store those IDs into an arraylist.</p>
  
  <pre><code>  if (jTabledetail.getRowCount() &gt; 0) {
          String ecode = "";
  
          int ishasRow = jTabledetail.getRowCount();// total 1 row
  
          for (int r = 0; r &lt;= ishasRow; r++) {// loop twice. First loop is gone, return to second loop or final loop for 1 row exists giving error bellow.
              ecode = jTabledetail.getValueAt(r, 0).toString();
              arrempcode.add(ecode);
          }
  
      }
  </code></pre>
  
  <h1>I also tried changing to ==>> for (int r = 0; r &lt; ishasRow; r++)  but not worked.</h1>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 1 &gt;= 1
               at java.util.Vector.elementAt(Vector.java:474)
               at javax.swing.table.DefaultTableModel.getValueAt(DefaultTableModel.java:648)
               at javax.swing.JTable.getValueAt(JTable.java:2717)
  </code></pre>
  
  <p>I don't understand the error. I known that the error comes from loop expression. I am not sure for this error. </p>
  
  <p>Now my jtable named "jTabledetail" has 1 row exists.</p>
  
  <p>Do I need to change something for this case of error? I am not sure that the loop expression is wrong.</p>
  
  <p>Thank you very much.</p>