-5

Whenever I try to run the following code Java tells me it cannot find symbol.

public class Quadratic {
    public static void main(String[] args) {
        double b = Double.parseDouble(args[0]);
        double c = Double.parseDouble(args[1]);
        double discriminant = b * b - 4.0 * c;
        double d = Math.sqrt(discriminant);
        System.out.println((-b + d) / 2.0);
        System.out.println((-b - d) / 2.0);
    }
}

I think it worked last week. Why do I keep getting this error?

Peter Mortensen
  • 30,738
  • 21
  • 105
  • 131
user2795731
  • 1
  • 1
  • 2

1 Answers1

2

When you think, it worked last week, you should recall what you did within that week which could break your existing code.

I suppose you have created a new class named Double. Without it, java automatically imports java.lang.Doubleif you use Double, but if you have a class with the same short name within your package, that class is preferred. And that class does not have the method parseDouble.

So you can do either, refer explicitly to java.lang.Double instead of just Double or remove the new Double class from your package.

But that’s just a guess. There’s too little information about your environment.

Holger
  • 285,553
  • 42
  • 434
  • 765