【发布时间】:2010-11-26 09:37:33
【问题描述】:
这是我的代码,我有一个 do-while 循环,除非输入的字符串“text”是“stop”,否则该循环应该继续。但是,当我编译代码时,它不会停止并陷入无限循环。豌豆帮助。谢谢。
import java.io.*;
public class input
{
public static void main(String[] argv) throws IOException
{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String text = "";
do
{
System.out.println("Please enter a string: ");
text = br.readLine();
System.out.println(text);
}
while (text != "stop");
}
}
【问题讨论】: