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?
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?
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.