Program to find greatest number in 2d array in java.

 class Max

{

    public static void main(String[] args) 

  {

        int [][] arr={{1,2,3},{4,5,6},{7,58,2}};


        int mx=Integer.MIN_VALUE;


        for(int i=0; i<arr.length; i++)

   {

            for(int j=0; j<arr[0].length; j++)

           {

                mx=Math.max(arr[i][j],mx);

            }

   }

        System.out.println("the maximum no. is ="+mx);

    }

}


■》 Output->

the maximum no. is =58

Comments

Popular posts from this blog

Introduction of java Programming language.

Stack data structure.