我刚刚下载了 JDK,安装了 JGrasp,并且正在尝试编写我的第一个 Java 程序(三角形的斜边)。这是我的程序:
public class Hypot {
public static void main(String args[]) {
double hypotenuse;
double d1;
double d2;
if (args.length != 2) {
System.out.println("You need to enter two arguments!");
System.exit(1);
}
try {
d1 = new Double.parseDouble(args[0]);
d2 = new Double.parseDouble(args[1]);
} catch (NumberFormatException nfe) {
System.out.println("Arguments need to be numbers!");
System.exit(2);
}
hypotenuse = Math.sqrt((d1 * d1) + (d2 * d2));
System.out.print("The hypotenuse of the right angle triangle with sides of " + d1 + "and" + d2 + "is" + hypotenuse);
}
}
我遇到了这两个错误;我真的不明白他们是什么。
Hypot.java:16: error: cannot find symbol d1= new Double.parseDouble(args[0]); ^ symbol: class parseDouble location: class Double Hypot.java:17: error: cannot find symbol d2= new Double.parseDouble(args[1]); ^ symbol: class parseDouble