방금 JDK를 다운로드하고 JGrasp를 설치했으며 첫 번째 Java 프로그램 (삼각형의 빗변)을 작성하려고했습니다. 여기에 내 프로그램이있다 :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
그냥 거기에서'new'을 제거하십시오. –