英文:
what arguments should i pass in this program so as to avoid java.lang error?
问题
这是我尝试运行的程序:
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)
Process finished with exit code 1
我无法理解为什么在我从合法来源复制代码时会出现此错误。
英文:
This is the prog i was trying to run :
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));
}
}
m getting this error on running this prog on 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)
Process finished with exit code 1
i couldn't understand why is this showing error when i copied the code from a legitimate source??
答案1
得分: 1
你目前传递了哪些参数?你的应用程序试图将字符串“console”转换为数字,因此出现了错误:
java.lang.NumberFormatException: For input string: "console"
英文:
What arguments are you currently passing? your application is trying to convert "console" String into a number, hence the error:
java.lang.NumberFormatException: For input string: "console"
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论