문제

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