作者hermeslu (左慈)
看板java
标题[问题] 从键盘输入多行字串,分行读取
时间Mon Aug 18 08:53:12 2008
程式要求linked将键盘输入的字串,一一串列。
假设每一行为同一字串,an empety line视为输入结束。
public static void main(String[] args) throws IOException {
Dlist theList = new Dlist();//这是一个double link
BufferedReader buf = new BufferedReader(
new InputStreamReader(System.in));
System.out.print("keyin a string: ");
String strReadLine = buf.readLine();
我的问题是为何我的while loop,
碰到empty line不会停止,
我是在windows作业系统用Eclipse console测试。
while (strReadLine!=null){
theList.insertLast(strReadLine);//这边是一个link建立的部分
strReadLine = buf.readLine();
}......程式以下未完
请问该如何修正?
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 149.171.8.207
1F:推 qrtt1:strReadLine!=null || !"".equals(strReadLine.trim()) 08/18 09:18