私はGrid
というクラスを作成しましたが、ネストされたArrayList
の容量を定義することは苦労しています。多次元arraylistの容量を定義する
this.contents = new ArrayList<ArrayList<GameObject>(cols)>(rows);
をしかし、これはエラーを与える:
public class Grid extends GameObject {
private int cols;
private int rows;
private int colWidth;
private int rowHeight;
private ArrayList<ArrayList<GameObject>> contents;
public Grid(int x, int y, int cols, int rows, int colWidth, int rowHeight, ID id) {
super();
this.x = x;
this.y = y;
this.cols = cols;
this.rows = rows;
this.colWidth = colWidth;
this.rowHeight = rowHeight;
//Here I want to define the contents
this.width = colWidth * cols;
this.height = rowHeight * rows;
this.id = id;
}
}
コードは次のようになります。これは私が現在持っているものです。誰もがこの問題を解決する方法を知っている、私は本当にそれを感謝します!前もって感謝します!
私はやっとそれが可能であることを望んだが、これはする必要があります。ありがとうございます! – Trashtalk