Initialize a two-dimensional array in matrix : Multidimensional Arrays « Collections « Java Tutorial






public class MainClass {
  public static void main(String args[]) {
    double m[][] = {
      { 0*0, 1*0, 2*0, 3*0 },
      { 0*1, 1*1, 2*1, 3*1 },
      { 0*2, 1*2, 2*2, 3*2 },
      { 0*3, 1*3, 2*3, 3*3 }
    };
    int i, j;
   
    for(i=0; i<4; i++) {
      for(j=0; j<4; j++)
        System.out.print(m[i][j] + " ");
      System.out.println();
    }
  }
}
0.0 0.0 0.0 0.0 
0.0 1.0 2.0 3.0 
0.0 2.0 4.0 6.0 
0.0 3.0 6.0 9.0








9.4.Multidimensional Arrays
9.4.1.Initialize a two-dimensional array in matrix
9.4.2.Arrays of Arrays
9.4.3.Arrays of Arrays in Varying Length
9.4.4.Defining Multidimensional Arrays
9.4.5.Array Of int Arrays
9.4.6.Get array upperbound
9.4.7.To get the number of dimensions
9.4.8.Array Of string Arrays