-3

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?

Wooble
  • 87,717
  • 12
  • 108
  • 131
  • 1
    This really has nothing to do with Eclipse; please use that tag only for questions about actually using the IDE. – Wooble Mar 18 '14 at 12:44
  • 1
    google would have helped you – Fraggles Mar 18 '14 at 12:48
  • You may want to have a look at [these docs](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CCgQFjAA&url=http%3A%2F%2Fdocs.oracle.com%2Fjavase%2Ftutorial%2Fjava%2Fnutsandbolts%2Fopsummary.html&ei=9EAoU43jOoPU2AXfpYCwCQ&usg=AFQjCNHzxxJmqCjY_maGVp83NAZJ2HR0JQ&sig2=BnqSVD0hF2hfuYzj_I-y8g&bvm=bv.62922401,d.b2I) – codeMagic Mar 18 '14 at 12:50
  • Instead of `or` you can use `|` or `||`.. For more information check this [link](http://stackoverflow.com/questions/7101992/why-do-we-usually-use-not-what-is-the-difference) – Thirupathi Sriramoji Mar 18 '14 at 12:55
  • "Can I do something like this?" Why didn't you just try the above code?! – DBedrenko Mar 18 '14 at 13:18
  • @NewWorld I tried that code but it didn't work that is why I posted it here. –  Mar 18 '14 at 13:20
  • @PranavGarg Ahh now I understand what you meant. – DBedrenko Mar 18 '14 at 13:24

1 Answers1

4

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

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

}

Where, || means OR.

Hamid Shatu
  • 9,664
  • 4
  • 30
  • 41