小编Pat*_*ean的帖子

我不断收到此错误:java.lang.ArrayIndexOutOfBoundsException:12

我的程序基本上采用 ISBN 编号列表并确定它们是否有效。所以错误是:s1[l]=digits[i][l-1]+digits[i][l]; 这行代码使用 for 循环计算 ISBN 编号的部分总和。下面的另一个循环取数组 s1 中所有整数的部分和。请帮忙?错误是:

Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: 12
at ISBN.main(ISBN.java:67)

  import java.util.*;
  import java.io.*;

  public class ISBN {
  public static void main(String [] args) throws IOException{
//Reads file line by line
  File ISBNFile = new File ( "isbn_input.txt" );
  Scanner input = new Scanner(ISBNFile);
  String [] preISBN = new String [9999];
  int i = 0;
  int j =0;
  int l =0;
  int m = 0;
  int count =0;
  while (input.hasNextLine()){
    String line …
Run Code Online (Sandbox Code Playgroud)

java eclipse arrays int indexoutofboundsexception

-3
推荐指数
1
解决办法
8287
查看次数

标签 统计

arrays ×1

eclipse ×1

indexoutofboundsexception ×1

int ×1

java ×1