测试输出是否表示已终止

问题描述 投票:0回答:1

我尝试过的以下代码必须能正常工作。当我在Eclipse中转到“运行方式”时,控制台什么也不显示,并且输出为空白。请帮忙。 注意,我删除了公共类并导入了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("\n Student " + ( i ) + " needs " + 
                studentData [i][0]*3 + " credits to graduate in " + studentData [i][1]); }}}}
java output
1个回答
0
投票

classesValiditytrue初始化,并且保持不变。反过来,从不执行while循环,并且程序仅对studentData进行迭代,而无需对其进行操作。

© www.soinside.com 2019 - 2024. All rights reserved.