Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
我有布爾類型 是爲什麼我會收到一個ArrayIndexOutOfBoundsException?
static boolean[][] a = new boolean[50][50];
每次獲取輸入, 它標誌着指定的數組爲真 即陣列,
for(int i=0; i<k; i++){
int x=sc.nextInt();
int y=sc.nextInt();
a[x][y] = true;
}
但是當數輸入,根據K,變大, 以下錯誤出來
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: -1
什麼不對這個
什麼是sc.nextInt()? – Kal
請更改您的問題標題。 :) – everton
K的價值是什麼? – slandau