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.
Pregunta
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?
Solución
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.