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?

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top