Java Double Array
Posted
by
user1062058
on Stack Overflow
See other posts from Stack Overflow
or by user1062058
Published on 2011-11-30T17:46:50Z
Indexed on
2011/11/30
17:50 UTC
Read the original article
Hit count: 155
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:
Exception in thread "main" java.util.NoSuchElementException
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 < 2; counter++) {
int index = 0;
index++;
nums[index] = in.nextDouble();
}
}
}
Thanks, I'm sure this isn't a hard question to answer... I appreciate your time.
© Stack Overflow or respective owner