I have a program that asks the user to enter a three-character string. A string can only be a combination of a, b or c.
How to check if a string contains any characters other than those specified without a million conditional statements.
Pseudo example:
String s = "abq"
if (s.containsOtherCharacterThan(a,b,c))
System.exit(-1)
source
share