pTutorial

New way to learn Programming

java array example

1 2 3
4 5 6
7 8 9

Java program to Print highest element in lower triangular matrix

class HighestElementInLowerHalf{
public static void main(String... z)
{
	int b=max(new int[][] {{1,200,3},{400,5,6},{7,8,9}});
	System.out.println("Highest number in this array="+b);
}

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

Output

Highest number in this array=400

See Also


QUOTES OF THE DAY

Crafty men condemn studies, simple men admire them, and wise use them.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER