I am working on a java project and was wondering how I could use a string to determine whether or not the chars in an array are valid. The given string is final String ALLOWED_CHARS = "01".
Say I have 2 char arrays:
char[] valid = {0,0,1,0,0,0,1,1,0,1}
char[] invalid = {0,0,1,0,0,A,1,1,0,1}
What would be an efficient way of determining valid and invalid arrays using the ALLOWED_CHARS string? I assume I am going to need to loop through the array and somehow compare each char to the chars in ALLOWED_CHARS but I'm not sure how to go about doing it.
char[]is soinvalid, it wouldn't even compile…