0
A
回答
-1
初始化
ArrayList<ArrayList<Integer>> mylistoflist = new ArrayList<ArrayList<Integer>>();
ArrayList<Integer> mylist = new ArrayList<Integer>();
然後你可以添加沒有這樣的問題:
mylistoflist .add(100);
mylistoflist .add(200);
mylist.add(100);
mylist.add(200);
如果添加到mylistoflist您將添加一個完全新的列表,否則,如果你加上MYLIST你會只需將一條記錄添加到列表中即可。 希望它可以幫助你
+1
'mylistoflist .add(100);'不會工作,因爲它期望一個ArrayList –
0
做這樣的:
ArrayList<Integer>[][] possibilities = new ArrayList[9][9];
當然現在你必須還初始化每個ArrayList
的二維數組中。但上面的例子應該編譯。
爲了初始化:
for (int i = 0; i < possibilities.length; i++){
for (int j = 0; j < possibilities[i].length; j++){
possibilities[i][j] = new ArrayList<Integer>();
}
}
然後你就可以像這樣訪問每個成員:
possibilities[0][0].add(2);
0
試試這個:
final int DIM = 9;
ArrayList<Integer>[][] possibilities = new ArrayList<Integer>[DIM][DIM];
for (int i = 0; i < DIM; i++)
for (int j = 0; j < DIM; j++)
possibilities[i][j] = new ArrayList<Integer>();
相關問題
- 1. 數組的ArrayList?
- 2. ArrayList和數組
- 3. ArrayList數組束
- 4. ArrayIndexOutOfBoundsException ArrayList的數組
- 5. 數組重寫ArrayList中的數組
- 6. Arraylist使用數組?
- 7. 如何將數組的ArrayList轉換爲數組數組
- 8. 將arraylist的arraylist轉換爲數組?
- 9. C#Sort Object ArrayList ArrayList中的數組?
- 10. Arraylist的Arraylist字符串數組
- 11. 數組對,ArrayList中的java
- 12. 2 ArrayList中的Java數組
- 13. 數組和ArrayList的感覺
- 14. 帶有可變數目數組的ArrayList
- 15. 對整數數組的ArrayList排序
- 16. ArrayList到字符串數組
- 17. 字符串數組ArrayList
- 18. 用ArrayList替換數組
- 19. 將數組更改爲ArrayList
- 20. 比較ArrayList和2D數組
- 21. 將ArrayList轉換爲數組
- 22. C#數組列表ArrayList
- 23. 爪哇 - ArrayList的 - 獲取從數組的數組
- 24. 將數組與ArrayList中的另一個數組進行比較
- 25. Java中的數組,需要數組,但是arrayList <string> found'
- 26. 將int數組的ArrayList傳遞給數組適配器
- 27. 將整數數組推送到ArrayList
- 28. ArrayList的用戶定義的類數組
- 29. 如何將ArrayList轉換爲數組數組?
- 30. 將ArrayList或數組轉換爲字符串數組
是我們用什麼語言?無論如何,只要查看多維數組是如何工作的。 – durbnpoisn
沒有進一步的信息只是一個猜測,但你仍然必須初始化該數組的每個元素,即對於每個「i」和「k」,'possible [i] [k] = new ArrayList <>()'。 –
您最好製作一個Cell類,它包含可能性和答案,然後定義一個9 x 9的2D單元格數組。 –