Write a java Program to check given matrix is null matrix

Write a java Program to check given matrix is null matrix

Write a java Program to check given matrix is null matrix

Program
public class Main
{
    public static void main(String args[])
    {
        int[][] a = new int[][] { { 0, 0, 0},{ 0, 0, 1},{ 0, 0, 0} };
        boolean setValue = true;
        abc: for(int i = 0;i < a.length;i++)
        {
            for(int j = 0;j < a[i].length;j++)
            {
                if(a[i][j] != 0)
                {
                    setValue = false;
                    break abc;
                }
            }
        
        }
        
        System.out.println("The Given Matrix Value:");
        
        for(int i = 0;i < a.length;i++)
        {
            for(int j = 0;j < a[i].length;j++)
            {
                System.out.print(a[i][j] + " ");
            }
            System.out.println();
        }
        if(setValue == true)
        {
            System.out.println("The Given Matrix is a Null Matrix");
        }
        else
        {
            System.out.println("The Given Matrix is not a Null Matrix");
        }
    }
}


Output:

The Given Matrix Value:
0 0 0
0 0 1
0 0 0
The Given Matrix is not a Null Matrix



More Questions


46 . Write a java program to add two matrix
47 . Write a java Program to check given matrix is null matrix
48 . Add all the digits of a given positive integer until the result has a single digit
49 . Write a Java program to accept a float value of number and return a rounded float value



For latest job updates join Telegram Channel: https://t.me/sateeshm

Apply For The Job

Apply For Job

Java Material

Python Material

PLSQL Material

.Net Material

Java Practice Programs

400 Java Programs