pTutorial

New way to learn Programming

Array in java example code

1 2 3
4 5 6
7 8 9

Java program to print lower triangular matrix

//java program to access lower half array element

class TringleExample{
public static void main(String... z){
    max(new int[][] {{1,2,3},{4,5,6},{7,8,9}});
}

static void max(int d[][]){
    for(int i=0;i<d.length;i++){
        for(int j=0;j<d[i].length;j++)
        {
            if(j==i+1)
            {
                break;
            }
            System.out.print(d[i][j]+"\t");
        }
        System.out.println("\t");
    }
}
}


Output

1		
4	5		
7	8	9		

See Also


QUOTES OF THE DAY

Each day provides its own gifts.

LIKE ON FACEBOOK

+1 ON GOOGLE

SHARE ON TWITTER