我的Java程序已编译,但控制台未产生任何输出。显示没有错误的消息

问题描述 投票:-2回答:1

我为硬件分配编译了程序,并且编译时没有错误。在控制台中,出现一条消息,指出“编译器正在使用classPath ='[C:\ Users \ see513 \ Desktop \ RamosSLE32,C:\ drjava.exe]'; bootClassPath ='null'”。我在大学使用计算机,在笔记本电脑上编译代码时也会发生这种情况。是否以错误的方式保存文件?不完全确定发生了什么。

我正在将DrJava与8.0_121编译器一起使用。

import java.util.Scanner;

public class RamosSLE32 { // Begin class

    static int age;

    public static void main(String[] args) { // Begin main()
        Scanner input = new Scanner(System.in);
        String correctPassword = "MonthyPython";
        char tryAgain = 'Y';
        char tryAgain2 = 'Y';
        String q1 = "%nWhat is the password?";
        String q2 = "%nEnter your age: ";

        while (Character.toUpperCase(tryAgain) == 'Y') {
            System.out.printf(q1);
            String password = input.nextLine();

            if (password.equals(correctPassword)) {
                System.out.printf(q2);
                age = input.nextInt();
            } else {
                System.out.printf("%nInvalid password!%nDo you want to try again? Y or N.");
                tryAgain = input.nextLine().charAt(0);

                if (age > 17) {
                    System.out.printf(
                            "%nShangri-La welcomes you to your earthly paradise!%nThank you! Have a nice day!");
                } else {
                    System.out.printf(
                            "%nSorry, NO underaged patrons allowed!%nDo you want to try again? Y or N.");
                    tryAgain2 = input.nextLine().charAt(0);
                }
            }
        }
    } // End main()
} // End class
java compiler-errors console classpath drjava
1个回答
-4
投票

如果有其他情况,您可以尝试将第二个改为另一个


-5
投票

您的代码中有错误:

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