[問題] 從鍵盤輸入多行字串,分行讀取
程式要求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
推
08/18 09:18, , 1F
08/18 09:18, 1F