1// Java program to print 3x3 matrix
2import java.io.BufferedReader;
3import java.io.IOException;
4import java.io.InputStreamReader;
5public class JavaPrint3x3Matrix
6{
7 public static void main(String[] args) throws IOException
8 {
9 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
10 int[][] inputNumber = new int[3][3];
11 int a, b;
12 String strMatrix;
13 System.out.println("Please enter elements to print 3x3 matrix: ");
14 for(a = 0; a <= 2; a++)
15 {
16 for(b = 0; b <= 2; b++)
17 {
18 strMatrix = br.readLine();
19 inputNumber[a][b] = Integer.parseInt(strMatrix);
20 }
21 }
22 System.out.println("Elements in 3x3 matrix are: ");
23 System.out.println("");
24 for(a = 0; a <= 2; a++)
25 {
26 for(b = 0; b <= 2; b++)
27 {
28 System.out.print(inputNumber[a][b] + "\t");
29 }
30 System.out.println();
31 }
32 }
33}