title: Java Double Array
body: <p>I'm having trouble setting up and placing values into an array using a text file containing the floating point numbers 2.1 and 4.3 each number is separated by a space - below is the error I'm getting:</p>
  
  <p>Exception in thread "main" java.util.NoSuchElementException</p>
  
  <pre><code>import java.util.*;
  import java.io.*;
  
  public class DoubleArray {
  
      public static void main(String[] args) throws FileNotFoundException {   
  
          Scanner in = new Scanner(new FileReader("mytestnumbers.txt"));
  
          double [] nums = new double[2];
  
          for (int counter=0; counter &lt; 2; counter++) {
              int index = 0;
              index++;
              nums[index] = in.nextDouble();
          }
      }
  }
  </code></pre>
  
  <p>Thanks, I'm sure this isn't a hard question to answer... I appreciate your time.</p>