#Does anyone know why when I type 'no' the while loop still equals true?
1 messages · Page 1 of 1 (latest)
in C, C++, Java, the above is not true
in Java if both string are intern() then it could be true
while(play == true) {
for(int i = 0; i < 3; ++i) {
++userTurn;
System.out.println("Would you like to roll?");
String userInput = scnr.next();
if ("no".equals(userInput) || (theDice.countNumOnes() == 2) || theDice.countNumOnes() == 3 || userTurn == 3 ) {
play = false;
}
}
}
you might as well use "no".equalsIgnoreCase(userInput)
thank you \
also yoda style to avoid NPE, by putting the constant on the LEFT
how do u get ur code in that box
W