import java.io.*;
public class TerminateWhen
{
public static void main(String args[]) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String str = "";
System.out.println("Type \"x\" to exit..");
do {
str = br.readLine();
System.out.println(str);
}
while(str!="x");
}
}
的問題是,即使將鍵入的「X」,循環不會退出..Java的緩衝讀者
見http://stackoverflow.com/questions/971954/difference-between-equals-and – 2010-09-15 07:38:00