title: How to populate an array list in a while loop
body: <p>My problem is this </p>
  
  <pre><code>Scanner sf = new Scanner(f);
  ArrayList&lt;String&gt; teamArr = new ArrayList&lt;String&gt;();
  int counterPopulate = 0;
  
  while(sf.hasNextLine()){
      teamArr[counterPopulate] = sf.nextLine();
      counterPopulate++;           
  }
  </code></pre>
  
  <p>Any solutions, this is surrounded by a try catch. 
  Getting the problem at this part <code>teamArr[counterPopulate] = sf.nextLine();</code></p>