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'作为所有值填充一个二维数组。我正在使用的代码是:
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); }