什么参数应该在这个程序中传递,以避免java.lang错误?

huangapple go评论78阅读模式
英文:

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"

huangapple
  • 本文由 发表于 2020年8月30日 15:13:42
  • 转载请务必保留本文链接:https://go.coder-hub.com/63654916.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定