<p>@MIT, it is less than array.length (I just used 8 instead of array.length) but, it’s still only reading the last value. If you run the program, the output is:</p>
public static double[] readFile(Scanner inFile)
{
double[] token = new double[8];
for(int i = 0; i < 8; i++)
{
while(inFile.hasNextDouble()) // YOUR PROBLEM.
{
token* = inFile.nextDouble();
}
}
return token;
}
</p>
<p>Switch your while and for loops. Right now, it’s going:</p>
<p>for(int i=0, blah blah) {
bad while loop {
token[0] = 0.0
token[0] = 1.1
and so on…</p>
<p>So you end up with token[0] = 8.8. Since your .hasNextDouble() method goes through the entire input, it skips the while loop after proceeding for loops and leaves token[1]-token[7] with values of 0.0.</p>
<p>As a general rule of thumb, keep your for loops inside of your while loops. </p>
<p>This is what I think. I don’t remember much from Java since Java sucks as a language.</p>
<p>I think people are too obsessed with “languages.” Java is as good as other languages as far as the basics go, and is considerably more robust than C++ and others. Learn about more datatypes and algorithms that the AP curriculum neglects (the AP doesn’t really cover any algorithms at all) before trying a new language</p>
<p>I would recommend trying a bunch of different things: web programming with a framework (Ruby on Rails for e.g.), databasing (SQL), parallel computing (C with MPI), and dataflow (LabVIEW for e.g.).</p>
<p>All radically different, but there’s a great chance you’ll run into at least 2-3 of them in the future.</p>