Two things wrong: You can't just specify multiple values with ||
(or &&
) like that. You need to specify both the left side and the right side explicitly each time.
Second, use equals to compare String
values, not the ==
(or in this case !=
) operators. ==
compares two object references to see if they are the same object.
} else if (!("a".equals(question) || "b".equals(question)))
Or an alternative is to make a temporary List and use contains, which might be clearer for longer lists of things to test:
} else if (!Arrays.asList("a", "b").contains(question))