Beginner Java learner here. Yesterday, the compiler was telling me that it "cannot find symbol" for Double.parseDouble()
. The only "solution" I have right now to circumvent this "error" is to use import java.lang.Double
. I never created any classes named Double
or Integer
, either. Can someone help me understand why the compiler is throwing this error and how to rectify it?
Sample code:
import java.util.Scanner;
public class doubleparse
{
public static void main(String[] args)
{
double number;
Scanner in = new Scanner(System.in);
System.out.print("Enter a number: ");
String input = in.nextLine();
number = Double.parseDouble(input);
}
}
Error:
doubleparse.java:13: error: cannot find symbol
number = Double.parseDouble(input);
^
symbol: method parseDouble(String)
location: class Double
1 error
Why does the compiler throw this message every time I use a parsing method? I've seen it throw this when I use the Integer.parseInteger()
method too.