can you have two conditions in an if statement

后端 未结 6 1523
鱼传尺愫
鱼传尺愫 2020-12-22 13:48

I\'m a beginner in coding. I was recently working with to create a chatting programme where a user will chat with my computer. Here is a part of the code:

Sy         


        
6条回答
  •  眼角桃花
    2020-12-22 13:59

    You're looking for the "OR" operator - which is normally represented by a double pipe: ||

     if (b.equals("good") || b.equals("it was good")) {
            System.out.println("Thank goodness");
     }  else if (b.equals("bad") || b.equals("it was bad")) {
            System.out.println("Why was it bad?");
            String c = scanner3.nextLine();
            System.out.println("Don't worry, everything will be ok, ok?");
            String d= scanner10.nextLine();
     }
    

提交回复
热议问题