title: Creating an ArrayList from data in a text file
body: <p>I am trying to write a program that uses two classes to find the total $ amount from a text file of retail transactions.  The first class must read the file, and the second class must perform the calculations.  The problem I am having is that in the first class, the ArrayList only seems to get the price of the last item in the file.  Here is the input (which is in a text file): </p>
  
  <p>$69.99 3 Shoes</p>
  
  <p>$79.99 1 Pants</p>
  
  <p>$17.99 1 Belt</p>
  
  <p>And here is my first class: </p>
  
  <pre><code>class ReadInputFile {
  static ArrayList&lt;Double&gt; priceArray = new ArrayList&lt;&gt;();
  static ArrayList&lt;Double&gt; quantityArray = new ArrayList&lt;&gt;();
  
  static String  priceSubstring = new String();
  static String quantitySubstring = new String();
  
  public void gatherData () {
  
  String s = "C:\\filepath";   
  try {
  
  
        FileReader inputFile = new FileReader(s);
  
        BufferedReader bufferReader = new BufferedReader(inputFile);
  
        String line;
  
        String substring = " ";
  
        while ((line = bufferReader.readLine()) != null)
  
  
        substring = line.substring(1, line.lastIndexOf(" ") + 1);
  
  
  
       priceSubstring = substring.substring(0,substring.indexOf(" "));
  
        quantitySubstring = substring.substring(substring.indexOf(" ") + 1 , substring.lastIndexOf(" ") );
  
  
        double price = Double.parseDouble(priceSubstring);
        double quantity = Double.parseDouble(quantitySubstring);
  
        priceArray.add(price);
        quantityArray.add(quantity);
  
        System.out.println(priceArray);
  
  
  } catch (IOException e) {
       e.printStackTrace();
  }
  }
  </code></pre>
  
  <p>The output and value of priceArray is [17.99], but the desired output is [69.99,79.99,17.99].</p>
  
  <p>Not sure where the problem is, but thanks in advance for any help!</p>