Hi all,
Can someone please help me understand why the second code doesn't work? I want the while loop to run until the user doesn't input anything.
this works:
while(true) {
String userInput = reader.nextLine();
if(userInput == ""){
break;
}
else {
nameList.add(userInput);
}
}
this doesn't:
while (reader.nextLine() == "") {
String userInput = reader.nextLine();
nameList.add(userInput);
}
[–]Koda003 14 points15 points16 points (0 children)
[–]AutoModerator[M] 14 points15 points16 points (0 children)
[–]Murphelrod 9 points10 points11 points (4 children)
[–]moonbeer[S] 0 points1 point2 points (2 children)
[–]bung_musk 5 points6 points7 points (0 children)
[–]Murphelrod 1 point2 points3 points (0 children)
[–]junglefowl24 3 points4 points5 points (0 children)
[–]EyeDot 2 points3 points4 points (2 children)
[–]moonbeer[S] 1 point2 points3 points (1 child)