boolean hasTaxes(){
return !state.equalsIgnoreCase("TX" || "NM" ||"VA" || "AZ" || "AK");
}
In the above code, I got The operator || is undefined for the argument type(s) java.lang.String, java.lang.String error… so does that mean || operator cannot be used in equalsIgnoreCase() argument?
You are trying to use the
||operator on a string which doesn’t work. Try this insteadYou have to use the
||operator with booleans, which are what are returned by theequalsIgnoreCasemethod.