I want to check a char variable is one of 21 specific chars, what is the shortest way I can do this?
For example:
if(symbol == (\'A\'|\'B\'|\'C\')){}
Option 2 will work. You could also use a Set or
Set
char[] myCharSet = new char[] {'A', 'B', 'C', ...}; Arrays.sort(myCharSet); if (Arrays.binarySearch(myCharSet, symbol) >= 0) { ... }