Java program to print a square matrix in Z form
import java . lang . * ; import java . io . * ; class GFG { public static void diag ( int arr [ ] [ ] , int n ) { int i = 0 , j , k ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < n ; j ++ ) { if ( i == 0 ) { System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; } else if ( i == j ) { System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; } else if ( i == n - 1 ) { System . out . print ( arr [ i ] [ j ] + " ▁ " ) ; } } } }