<分区>
我正在计算应用程序中插入的 max
高度,它给我一个 ArrayIndexOutOfBound
错误,插入值的时间与长度相同包含 0 索引的数组,但我仍然遇到此错误。
int nrPersons = 3;
double[] height = new double[nrPersons];
double maxHeig = 0;
for (int i = 0; i <= nrPersons; i++) {
Scanner in = new Scanner(System.in);
in.useLocale(Locale.US);
System.out.println("Insert Height");
height[i] = in.nextDouble();
if (height[i]> maxHeig)
maxHeig = height[i];
}
System.out.println("The max Height is: "+maxHeig);