Here is the thing. I have a character array as follows..
char[] modes = new char[] { 'm', 'q', 'h', 'y' };
Now I want to provide the user with the option to enter a character. If it exists in the modes array, I'll do the necessary. For that I used...
//to take a character as input
mode = input.next().charAt(0);
//now to check if the array contains the character
boolean ifExists = Arrays.asList(modes).contains(mode);
But strangely ifExists returns false.
- Any Ideas where am I doing wrong?
- If this is a bad way of doing it, please suggest a way.
a.ifExistsis evaluated print the value ofmodeand the value of all contents in themodesarray. Probably, some value is not what you expect...binarySearchmethod onArrays?