为什么我不明白这一点 i的fillArray方法,最终等于10即使阵得分仅填充最多index 9.
根据我的理解i必须小于10,所以如何最终10结束,它应该增加.
我尝试了另一个循环来测试for循环是否在条件为真时执行递增.
在测试循环中i最终只有10个有意义,但两个for循环相矛盾.
public class GoldScores {
public static final int MAX_NUMBER_SCORES = 10;
public static void main(String[] args) {
double[] score = new double[MAX_NUMBER_SCORES];
int numberUsed = 0;
System.out.println("This program reads gold scores and shows");
System.out.println("how much each differs from the average.");
System.out.println("Enter gold scores:");
//numberUsed = fillArray(score);
// showdifference(score,numberUsed);
for(int i=1; i<11; i++){ //Test loop
System.out.println("Count is: " + i); …Run Code Online (Sandbox Code Playgroud)