title: Iterating through array list in Java
body: <p>I have an <code>ArrayList</code> which holds employee record details from data inputted into <code>JTextFields</code>. I have displayed this with a <code>showMessageDialog</code> box to confirm that they are being added to the list correctly.</p>
  
  <p>The employees are created and added to the list correctly but how do I cycle through the <code>ArrayList</code> one record at a time and have the information displayed in the <code>JTextFields</code>?</p>
  
  <p>Edited as below:</p>
  
  <p>I don't think I have asked the question properly. I have a button that enables me to show the contents of the first element of my array list to the GUI. See below: </p>
  
  <p><code>nField.setText(nameList.get(0).getName());</code>
  <code>bField.setText(nameList.get(0).getBirth());</code>
  <code>jField.setText(nameList.get(0).getID());</code></p>
  
  <p>What I need is something to show the next element. </p>
  
  <p>I have a list iterator that I am trying to use but I simply can’t get it to work.</p>
  
  <p>I have tried this but it results in the last element being shown:</p>
  
  <p><code>for (int i = 0; i &lt; nameList.size(); i++) {</code></p>
  
  <p><code>nameList.get(i);</code></p>
  
  <p><code>nField.setText(nameList.get(i).getName());</code>
  <code>bField.setText(nameList.get(i).getBirth());</code>
  <code>jfield.setText(nameList.get(i).getID()); }</code></p>