6:14 am - Sunday October 22, 2017

Java Example Program for lower triangular matrix

CANDID INDUSTRIAL TRAINING -- CHENNAI
Corporate Training for Experienced Candidate
Struts | Hibernate | Spring | Java / J2EE
SOAP | RestFull | Design Pattern | more...
Ph: +91 72000 69003
137b, 2nd st, shanthi nagar, Chrompet, Chennai -600044

 


public class MainLTM {
public static void main(String args[]) {
int[][] a = new int[3][3]; // declaration of an array. here array a
// contain 3-rows and 3-columns.
a[0][0] = 1; // here initializing 1st element of an array
a[0][1] = 0;
a[0][2] = 0;
a[1][0] = 5;
a[1][1] = 1;
a[1][2] = 0;
a[2][0] = 9;
a[2][1] = 6;
a[2][2] = 3;

for (int i = 0; i < a.length; i++) // Here a.length is 3 ie i<3. { for (int j = 0; j < a[i].length; j++) // here a[i].length=3 ie. j<3. { System.out.print(a[i][j] + " "); // here printing an array // elements. } System.out.print("\n"); } } } [/java]

Output

1 0 0

5 1 0

9 6 3

 

Filed in: Sample Programs in java

Comments are closed.