[問題] 字串陣列存放 readLine() 的問題

看板java作者 (...)時間19年前 (2006/08/25 00:30), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串1/3 (看更多)
我是想要把從txt中讀出來的東西放進去string陣列中 FileReader fin = new FileReader("123.txt"); BufferedReader lnr = new BufferedReader(fin); String[] s = new String[100]; int i = 0; while(str != null) { String str = lnr.readLine(); s[i] = str; <-------------------這一行錯了 i++; } 我這樣寫會出現下面的錯誤 found : java.lang.String required: java.lang.String[] 想請教一下各位大大 readLine方法讀進來的資料不是string型態嗎? 怎麼不能放進去string陣列中呢? PS:剛接觸JAVA很多地方不懂的新手 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 219.70.164.190 ※ 編輯: James0315 來自: 219.70.164.190 (08/25 11:39)
文章代碼(AID): #14xTGq7t (java)
文章代碼(AID): #14xTGq7t (java)