Java Array multidimensional Arrays print array

Description

Java Array multidimensional Arrays print array

import java.util.Arrays;

public class Main {

  public static void main(String[] args) {
    int[][] matrix = { { 1, 2 }, { 3, 4 }, { 5, 6 } };

    System.out.println(Arrays.deepToString(matrix));
    for (int row = 0; row < matrix.length; row++) {
      for (int column = 0; column < matrix[row].length; column++) {
        System.out.print(matrix[row][column] + " ");
      }//www.  j  a v a 2s. c o m

      System.out.println();
    }
  }
}



PreviousNext

Related