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

看板java作者 (Believing is seeing! ^^)時間19年前 (2006/08/25 15:13), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串2/3 (看更多)
※ 引述《James0315 (...)》之銘言: : 我是想要把從txt中讀出來的東西放進去string陣列中 : FileReader fin = new FileReader("123.txt"); : BufferedReader lnr = new BufferedReader(fin); : String[] s = new String[100]; : int i = 0; : while(str != null) ^^^ cannot find symbol // 你宣告在迴圈內 : { : String str = lnr.readLine(); : s[i] = str; <-------------------這一行錯了 : i++; : } : 我這樣寫會出現下面的錯誤 : found : java.lang.String : required: java.lang.String[] : 想請教一下各位大大 readLine方法讀進來的資料不是string型態嗎? : 怎麼不能放進去string陣列中呢?   在更正前述錯誤後重新編譯,   並未出現如你所說的錯誤耶!? (編譯成功 @@) : PS:剛接觸JAVA很多地方不懂的新手 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 59.113.96.157
文章代碼(AID): #14xgC2oY (java)
文章代碼(AID): #14xgC2oY (java)