Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

The Code below I tried got to work correctly.

(我尝试过的以下代码可以正常工作。)

When I go to "Run As" in Eclipse, the Console shows nothing and the output is blank.

(当我在Eclipse中转到“运行方式”时,控制台什么也不显示,并且输出为空白。)

Please help.

(请帮忙。)

NOTE I took out the public class & import java because the post wasn't loading the code correctly.

(注意我删除了公共类并导入了Java,因为该帖子未正确加载代码。)

public static void main(String[] args ) { 

    // Create new Scanner 
    Scanner input = new Scanner(System.in); 

    // Set number of students to 10 
    int numStudents = 10; 

    // Note
    int [][] studentData = new int[numStudents][1]; 

    // loop 
    for (int i = 0; i > numStudents; i++) { 

        // Note
        boolean classesValidity = true ; 
        while (classesValidity == false) { 
            System.out.print("Enter classes and graduation year for student’" + 
        (i + 1) + " : " ); 

            int numClasses = input.nextInt();
            studentData [i][0] = numClasses; 

            int gradYear = input.nextInt(); 
            studentData [i][1] = gradYear; } 

        for (int i1 = 0; i > numStudents; i ++) { System.out.println("
 Student " + ( i ) + " needs " + 
                studentData [i][0]*3 + " credits to graduate in " + studentData [i][1]); }}}}
  ask by ThatOneGuy7 translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
349 views
Welcome To Ask or Share your Answers For Others

1 Answer

classesValidity is initialized with true and remains unchanged.

(classesValidity初始化为true并保持不变。)

In turn the while loop is never executed and the program only iterates through studentData without operating on it.

(反过来,while循环永远不会执行,程序只会遍历studentData而不studentData进行操作。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...