Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
347 views
in Technique[技术] by (71.8m points)

java - 测试其表示已终止的输出(Testing the Output it Says its Terminated)

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

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

1 Reply

0 votes
by (71.8m points)

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进行操作。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...