Mazzy
Mazzy

Reputation: 14227

Create matrix of object

Hi I have to create a matrix of object with certain dimension.is it possible.the dimension of the matrix are int while the content are object.How can I do?

Upvotes: 1

Views: 15350

Answers (2)

Baptiste Wicht
Baptiste Wicht

Reputation: 7683

A little search does not harm. It's really simple.

Object[][] matrix = new Object[rows][cols];

Upvotes: 5

Jeff Foster
Jeff Foster

Reputation: 44746

You need something like

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();

Upvotes: 5

Related Questions