next up previous
Next: Number of rows and Up: Unit 07 Previous: Matrices

Expressions that denote matrix objects

Since a matrix is simply an array whose elements are themselves arrays, in the initialization of a matrix we can use an expression that denotes a matrix.

Example:

int[][] m = { { 3, 5  },
              { 1, -2 }
            };

Note that the definition of the matrix above is equivalent to:

int[][] m = new int[2][2];
m[0][0] = 3; m[0][1] = 5;
m[1][0] = 1; m[1][1] = -2;


next up previous
Next: Number of rows and Up: Unit 07 Previous: Matrices