Reputation: 1519
I want to perform the same operation for more than one value of a string called contents
if (contents == "chicken roll" , contents == toasted chicken){
// do some common operation
}
What is the proper Java syntax for this?
Upvotes: 0
Views: 342
Reputation: 838306
I think you want a logical or ||
:
if (contents.equals("chicken roll") || contents.equals("toasted chicken")){
See the list of operators.
Also note that you compare for string equality using the equals
method.
Upvotes: 2