问题描述
这是我试图运行的程序:
public class RightTriangle {
public static void main(String args[]) {
int a = Integer.*parseInt*(args[0]);
int b = Integer.*parseInt*(args[1]);
int c = Integer.*parseInt*(args[2]);
System.out.println((c*c==a*a+b*b||b*b==a*a + c*c ||a*a == b*b + c*c)&&(c>0 && b>0 && a>0));
}
}
在IntelliJ上运行此编时出现此错误:-
"C:\Program Files\Java\jdk-14.0.2\bin\java.exe" "-javaagent:C:\Users\anuavi\IntelliJ IDEA Community Edition 2020.2.1\lib\idea_rt.jar=58608:C:\Users\anuavi\IntelliJ IDEA Community Edition 2020.2.1\bin" -Dfile.encoding=UTF-8 -classpath C:\Users\anuavi\IdeaProjects\java1\out\production\java1 RightTriangle console
Exception in thread "main" java.lang.NumberFormatException: For input string: "console"
at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:68)
at java.base/java.lang.Integer.parseInt(Integer.java:652)
at java.base/java.lang.Integer.parseInt(Integer.java:770)
at RightTriangle.main(RightTriangle.java:7)
解决方法
您当前正在传递哪些参数?您的应用程序尝试将“控制台”字符串转换为数字,因此出现错误:
java.lang.NumberFormatException: For input string: "console"