// This is the fully general way to initialise a matrix. // There are shorter ways to specify initialisation, // but this is always what happens under the covers. // Note how you never specify the array's size in its type declaration. int[][] mat; // for each row, allocate a slot for a pointer to an array mat = new int [3][]; for ( int i=0; i<3; i++ ) { // allocate an array for each row mat[i] = new int[5]; for ( int j=0; j<5; j++ ) { mat[i][j] = i*j+100; } }