Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
すべての値として '-1' で 2D 配列を埋めようとしています。私が使用しているコードは次のとおりです。
int c [] []=new int[4][4]; Arrays.fill(c,-1)
これにより、次のエラーがスローされます。
Exception in thread "main" java.lang.ArrayStoreException: java.lang.Integer
コードの何が問題なのか誰か教えてください。
整数の配列の配列です。
あなたは書くべきです
int c [] []=new int[4][4]; for(int[] arr : c){ Arrays.fill(arr,-1); }