Java program to find maximum and minimum numbers in the given matrix

By | December 25, 2018

In this post of Java program to find maximum and minimum numbers in the given matrix.
We will learn how to write a java program to find the maximum and minimum number in the given matrix (2-Dimensional Array).

Logic here what we used to have two variables for maximum and minimum numbers, initially assign the element at the first index of the matrix to both the variables.

After that iterate the matrix one row at a time and compare each column element with the max number if max number is less than the column element then assign column element to the max number.

If we find max number is greater than the column element then check if minimum number is greater than the column element, if yes then assign column element to the minimum number.

You may also like –
Find largest and smallest number in the given Array
Find duplicate elements in an Array
Java program to Remove Duplicate Elements From an Array
Java program to add two matrices
Matrix Subtraction Java program

Java program to find maximum and minimum numbers in the given matrix

Program output for 3X4 Matrix:

That’s all for this topic Java program to find maximum and minimum numbers in the given matrix. If you have any doubts or any suggestions to make please drop a comment. 

Leave a Reply

Your email address will not be published. Required fields are marked *