Java do while loop making string testing act differently
I am very confused at the behavior of using the || operator on the .equals function. Is there a reason I can not use it on strings or something? this works: do{ System.out.println("Play again? [Y/N]"); //input: Y play = in.nextLine(); play = play.toUpperCase(); } while(!"Y".equals(input) ); //breaks out of loop (as it should) why doesn't this work?! do{ System.out.println("Play again? [Y/N]"); //input: Y play = in.nextLine(); play = play.toUpperCase(); } while( !"Y".equals(input) || !"N".equals(input) ); //infinite loop Let's put it into words. "Eat all of this fruit as long as it's not an