// Using length instead of hard-coded constants static final int NUM_ROWS = 3; static final int NUM_COLS = 5; int[][] mat = new int [NUM_ROWS][NUM_COLS]; for ( int i=0; i<mat.length; i++ ) { for ( int j=0; j<mat[i].length; j++ ) { mat[i][j] = i*j+100; } }