Why doesn’t my loop end when I enter “Done”?
List<String> x = new ArrayList<String>();
BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while (line != "Done")
{
System.out.println("?> ");
line = is.readLine();
x.add(line);
}
You have to use
equalswhen comparing strings. Try this:!=will check the reference, not the content of the string.