Try this:
import java.io.*;
import java.util.*;
class Tmp
{
public static void main (String[] args) throws IOException
{
List<String> x = new ArrayList<String>();
BufferedReader is = new BufferedReader(new InputStreamReader(System.in));
String line = "";
while (line.compareTo ("Done") != 0)
{
System.out.print("?> ");
line = is.readLine();
x.add(line);
System.out.println ("IO: " + line + "...");
}
}
}
The issue is that "==" compares the object reference of the string constant "Done" to the reference to the other string object "line". Since they're two different objects, their references are never equal.
Instead, you need to COMPARE the value "Done" to the value of "line".
'Hope that helps!
PS:
When I saw this question, there were no replies.
It never takes me any less than 10-15 minutes to formulate and test a reply.
By which time multiple other replies inevitably squeeze in.
I don't do "fast" ;)
But I try my best for "accurate" ;)