创建对象矩阵

Maz*_*zzy 1 java multidimensional-array

您好,我必须创建一个具有特定维度的对象矩阵。是否可能。矩阵的维度是 int,而内容是对象。我该怎么办?

Jef*_*ter 5

你需要类似的东西

myobjectMatrix foo[][] = new myobjectMatrix[width][height]

// Remember that everything in the matrix is initialized to null so
// you must initialize everything
foo[0][0] = new myobjectMatrix();
Run Code Online (Sandbox Code Playgroud)


Bap*_*cht 5

稍微搜索一下并没有什么害处。这真的很简单。

Object[][] matrix = new Object[rows][cols];
Run Code Online (Sandbox Code Playgroud)