12:54 pm - Thursday July 27, 2017

Java Program for Upper 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 MainUTM {
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] = 5; // here initializing 1st element of an array
a[0][1] = 3;
a[0][2] = 8;
a[1][0] = 0;
a[1][1] = 2;
a[1][2] = 9;
a[2][0] = 0;
a[2][1] = 0;
a[2][2] = 1;
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

5 3 8

0 2 9

0 0 1

 

Filed in: Sample Programs in java

Comments are closed.