Java - Print the 3 x 3 matrix

Introduction

Using a for Loop to Print a 3x3 Matrix

Demo

public class Main {
  public static void main(String[] args) {
    // Outer for-loop statement
    for (int i = 1; i <= 3; i++) {
      // Inner for-loop statement
      for (int j = 1; j <= 3; j++) {
        System.out.print(i + "" + j);
        // Prints a tab after each column value
        System.out.print("\t");
      }//from   w w w .j  a v  a 2  s  .c o  m

      System.out.println(); // Prints a new line
    }

  }
}

Result

Related Example