While loop not looping need help
This loop will only go through the first time and when the user types Y at the bottom it wont reloop even though the value for ques is Y.
Code:
String ques = "Y";
while (ques == "Y") {
System.out.println("Enter a word.");
String str = br.readLine();
str = str.toUpperCase();
if ( ( str.indexOf('R') == -1 ) || ( str.indexOf('N') == -1) ) {
System.out.println("The word does not contain an 'r' and an 'n'.");
}else if ((str.indexOf('R')) < (str.indexOf('N'))) {
System.out.println("'R' comes before 'N' in: " + str);
}else{
System.out.println("'N' comes before 'R' in: " + str);
}
System.out.println("Continue? (Y/N)");
ques = br.readLine();
System.out.println(ques);
}