String currentLine = reader.readLine();
while (currentLine != null)
{
String[] studentDetail = currentLine.split("");
String name = studentDetail[0];
int number = Integer.valueOf(studentDetail[1]);
currentLine = reader.readLine();
}
所以我有這樣一個文件:Integer.valueOf()錯誤ArrayIndexOutOfBoundsException異常:
student1
student16
student6
student9
student10
student15
當我運行節目中說: ArrayIndexOutOfBoundsException異常:1
輸出應該是這樣的:
student1
student6
student9
student10
student11
student15
student16
你需要發佈更多的代碼。 –
您可以調試以查找變量名稱包含的內容,因爲IndexOutOfBounds指示已使用非法索引訪問數組。索引或者是負數,或者大於或等於數組的大小。 –
你需要知道什麼? – Camila