Search code examples
javaif-statementoperatorslogical-or

Java - Multiple accepted inputs"


I was just curious how you would accept multiple inputs in Java, from what I have tried you're unable to use the logical OR operators ||.

So if I wish to have multiple accepted inputs accepted for an IF statement how would I do this? if (userinput.equalsIgnoreCase("House" || "Home")) How can I have both House and Home activate this without creating an else statement?


Solution

  • Use

    if((userinput.equalsIgnoreCase("House")) || (userinput.equalsIgnoreCase("Home")))