How do you stop a program from running in a blueprint class using a nested if statement and not a System.exit(0);?

时间:2019-03-17 22:32:48

标签: java

In this code I tried to stop the program from running by using System.exit(0);

Is there a possible way to exit the program using a nested if statement and not using System.exit(0);

public String answerR1()
{
    if (answer .equals ("snow"))
    {
        message = "\nCorrect!";
    }
    else
    {
        message = "\nIncorrect!";
        System.exit(0);
    }
    return message;
}
public String answerR2()
{
    answer = answer.toLowerCase();
    if (answer .equals ("time"))
    {
        message = "\nCorrect!";
    }
    else
    {
        message = "\nIncorrect!";
        System.exit(0);
    }
    return message;
}
public String answerR3()
{
    if (answers == 20)
    {
        message = "\nCorrect!";
    }
    else
    {
        message = "\nIncorrect!";
        System.exit(0);
    }
    return message;
}

1 个答案:

答案 0 :(得分:-2)

YearMonthPicker

尝试使用Break代替System.exit(0);