pTutorial

New way to learn Programming

Java two dimensional array Minimum

Java program for finding the minimum integer in the following two dimensional array with the help of loop. You can make this java program user define by using previous example.

Java two dimensional array min

//find minimum number without sorting an two diementional array
class MinimumInTwoDiementionalArray{
public static void main(String... z){
    int b=max(new int[][] {{10,1,330},{50,30000,1000},{70,5,20}});
    System.out.println("Minimum number in this array is ="+b);
}

static int max(int d[][])
{
    int c=d[0][0];
    for(int i=0;i<d.length;i++){
        for(int j=1;j<d.length;j++){
            if(c>d[i][j]){
                c=d[i][j];
            }
        }
    }
    return c;
}
}

Output

Minimum number in this array is = 1

See Also


QUOTES OF THE DAY

Beauty is truth, Truth beauty- That is all

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER