string and condition problem
I am trying to perform a task that checks the letter that user inputs (ignoring case) and return the desired:
if the letter contains "System.out.print ("right")
if not "--> Not a valid request "
i did the following code but in either cases it returns as "--> Not a valid request "
String letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
Scanner kb = new Scanner(System.in);
String guessWord = kb.next();
if (guessLetter.contains(letters) ||guessLetter.toLowerCase().contains(letters))
else System.out.println("--> Not a valid request " +
"- either not a letter or already guesses. ");
reply to string and condition problem
check your condition there is a mistake in name of variables
it should be as follow
if (letters.contains(guessWord) ||letters.toLowerCase().contains(guessWord))