Can I use any 'or' like word in an if else statement (in contentEquals() )

103 views Asked by At

I was thinking if we could use 'or' or anything like that in Java Eclipse Android Development when I write this code

 if (strName.contentEquals("Hi" or "Hello") {

}

Can I do something like this?

1

There are 1 answers

0
Hamid Shatu On BEST ANSWER

Use Conditional-OR (||) operator as below...

if (strName.equals("Hi") || strName.equals("Hello")) {

}

Where, || means OR.