Question

I'm trying to put the answer in a variable but I get stuck in this error:

    double p1;

    String text = JOptionPane.showInputDialog("Type the grade of p1");
    p1 = double.parseDouble(text);

when i use the double.parseDouble(text) I get "double cannot be dereferenced" in the Netbeans ID.E

What am I doing wrong?

Was it helpful?

Solution

Use the class name with a capital D:

p1 = Double.parseDouble(text);

The parseDouble method is in the Double class. If it's lowercase, that refers to the primitive type double which generates your compiler error.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top