本文介绍了JAVA Eclipse中的数组索引超出界限的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好!
请光临我。我知道之前有人问这个问题,但我找不到解决办法。我重新创建的这个示例来自JAVA教程网站。我读了那个并重新创建了它。我不知道如何解决这个问题以及如何
hello!
Please bare with me. I know this question was asked before but I just can`t find a solution. This example that I recreated is taken from a JAVA tutorial website. i read that and recreated it. I have no idea how to fix this and how
args[0]
是Out Of Of界限。
这是代码:
is Out Of Bounds.
Here is the code:
public class Sqrtcalc {
public static void main (String[] args) {
double b = Double.parseDouble(args[0]);
double c = Double.parseDouble(args[1]);
double a = Double.parseDouble(args[2]);
double Delta = b*b - 4.0*a*c;
double sqrootD = Math.sqrt(Delta);
double N1 = (-b + sqrootD)/ (2.0*a);
double N2 = (-b - sqrootD)/ (2.0*a);
System.out.println(N1);
System.out.println(N2);
}
}
这就是错误。如果我删除
And this is the Error. If i remove
double b
它只是移动到下一个值(Double c)并且同样的事情。
it just moves to the next value (Double c) and says the same thing.
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 0
at Sqrtcalc.main(Sqrtcalc.java:6)
第6行是双b的那个。
感谢您的帮助和时间!
line 6 being the one with Double b.
Thank you for your help and time!
推荐答案
这篇关于JAVA Eclipse中的数组索引超出界限的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!