jeudi 28 octobre 2021

Is there a way that I can put two or more words string with spaces in if else statement?

I want to input something like without the snake cases or underscore, like only "Nothing is true." and not "Nothing_is_true." but every time I do that it's not reading the if statement.

Is there any other way to do it?

I'm new to coding, sorry if you find my question so dumb

public static void main(String[] args) {
    Scanner inp = new Scanner(System.in);
    String answer1;
    System.out.println("When men are blindly following the truth, remember...");
    answer1 = inp.next();
    if (answer1.equals("Nothing_is_true.")) {
        System.out.println("Correct.");
    } else System.out.println("Wrong.");
}

Aucun commentaire:

Enregistrer un commentaire