title: Reading numbers from a text file into an ArrayList in Java
body: <p>Can anyone show me a basic guideline for how to do this sort of thing? Would you use an Array or an ArrayList, and why? Anything else I've found online is too complicated to understand for my level of experience with Java. The file is a simple text file with seven decimal values per line, and contains three lines. Here is what I have so far and am just testing it to see if I'm doing the ArrayList properly. It keeps printing an empty ArrayList that is just two brackets.</p>
  
  <pre><code>import java.io.File;
  import java.io.FileNotFoundException;
  import java.util.ArrayList;
  import java.util.Scanner;
  
  public class SalesAnalysis 
  {
      public static void main (String[] args) throws FileNotFoundException
      {
  
          Scanner salesDataFile = new Scanner(new File("SalesData.txt"));
  
          ArrayList&lt;Double&gt; salesData = new ArrayList&lt;Double&gt;();
  
          while(salesDataFile.hasNextDouble())
          {
              salesData.add(salesDataFile.nextDouble());
          }
          salesDataFile.close();
  
          System.out.println(salesData);
  
      }
  }
  </code></pre>