Program to Execute the in Java Program to Display the Upper Triangular Matrix. A square matrix with all of the elements below the primary diagonal being zero is known as an upper triangular matrix. To find the upper triangular matrix, the matrix must be square, which means that the number of rows and columns must be equal.

## Display the Upper Triangular Matrix

Upper triangular matrix is a square matrix with elements sij = 0 for j i. In other words, if all of the entries below the main diagonal are zero, a square matrix is upper triangular. In other words, if all of the entries above the main diagonal are zero, a square matrix is lower triangular.

## Matrix in Maths

A matrix is a rectangular array of numbers that are arranged in rows and columns. The numbers are referred to as the matrix’s elements or entries. Engineering, physics, economics, and statistics, as well as various branches of mathematics, all use matrices.

A matrix is a rectangular array of numbers or symbols organised in rows and columns. We have a 32 matrix in this example because the number of rows is equal to 3 and the number of columns is equal to 2. Using this program we can execute Java Program to Display the Upper Triangular Matrix.

## Implement 3*3 Matrix in Java Program

Using the binary * operator and another loop, we can multiply two matrices in Java. A matrix can also be referred to as an array of arrays. Matrixes can be added, subtracted, and multiplied.

When multiplying two matrices, one row element of the first matrix is multiplied by all columns of the second matrix. We can implement Java Program to Display the Upper Triangular Matrix to execute matrix program.

## If Else in Java Program

The simplest basic decision-making statement in Java is the if statement. It is used to determine if a statement or a block of statements will be executed or not, that is if a condition is true, a block of statements will be executed; otherwise, it will not. Otherwise known as else if, else if is a conditional statement that is executed after an if statement and executes a function if true.

```
public class Main
{
public static void main(String[] args) {
int rows, cols;
int a[][] = {
{3, 2, 3},
{5, 6, 4},
{7, 5, 6}
};
rows = a.length;
cols = a[0].length;
if(rows != cols)
{
System.out.println("Matrix should be a square matrix");
}
else {
System.out.println("Upper triangular matrix is");
for(int i = 0; i < rows; i++){
for(int j = 0; j < cols; j++){
if(i > j)
System.out.print("0 ");
else
System.out.print(a[i][j] + " ");
}
System.out.println();
}
}
}
}
```

Output:

Upper triangular matrix is

3 2 3

0 6 4

0 0 6