[問題] 應該是個小問題
我剛開始學java ,
所以我只是在試試看而已 ^^
現在我只是new出一個(int)鎮列,
然後一個一個填值,
//buffer的宣告
BufferedReader buf;
buf = new BufferedReader(new InputStreamReader(System.in));
for(int i=0;i<num;i++){ // num是 宣告的陣列大小
// System.out.println("enter content :"+i);
s= buf.readLine();
// System.out.println(s);
score[i] = Integer.parseInt(s);
}
build會過,
但是只要執行到第二次迴圈就會錯,
但是我只要把打註解的那兩行中的 "任一行" 註解拿掉就會正常運作了,
我不知道差在哪裡,
以下是執行時的錯誤訊息,
java.lang.NumberFormatException: For input string: ""
at
java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
at java.lang.Integer.parseInt(Integer.java:447)
at java.lang.Integer.parseInt(Integer.java:476)
at hello_world.func5(hello_world.java:116)
at hello_world.main(hello_world.java:29)
Exception in thread "main"
Process completed.
感謝您的回應!!
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.247.237
推
01/21 18:24, , 1F
01/21 18:24, 1F
推
01/21 18:50, , 2F
01/21 18:50, 2F
→
01/21 18:50, , 3F
01/21 18:50, 3F
※ 編輯: akdsy 來自: 140.116.247.237 (01/21 19:13)
推
01/21 20:00, , 4F
01/21 20:00, 4F
推
01/21 20:20, , 5F
01/21 20:20, 5F
→
01/21 21:03, , 6F
01/21 21:03, 6F
討論串 (同標題文章)