So I'm having trouble parsing a double...

Here's my code:

public class DoubleArray
{
    static Console c;           // The output console
    static final int total = 20;
    String[] numStr = new String [total];
    Double numDouble;

    public void getAndStoreInput ()
    {
        int count = 0;
        do
        {
            c.print ("Enter Double" + (count + 1));
            c.print (": ");

            while (true)
            {
                try
                {
                    numStr [count] = c.readLine ();
                    numDouble = Double.parseDouble (numStr [count]);
                    if ((numStr [count] = c.readLine ()) == null || count < total)
                    {
                        break;
                    }
                    count++;
                }
                catch (NumberFormatException e)
                {
                    new Message ("That's not a number. Please try again.");
                }
            }
        }
        while (count < total);

    }

Error occurs here:

numDouble = Double.parseDouble (numStr [count]);

I've been able to parse Double before but I don't know why it's erroring now?

what error message do you get? have you read it?
in about 99.99% of all cases it tells you exactly what goes wrong and where it goes wrong.

You cannot assign a "double" expression to a "java.lang.Double" variable. That's the error message.

Nevermind, I used Double instead of double.. Thanks

Edited 4 Years Ago by Daigan: n/a

This question has already been answered. Start a new discussion instead.