Go4Expert

Go4Expert (http://www.go4expert.com/)
-   Java (http://www.go4expert.com/forums/java/)
-   -   Printint 2-d Array (http://www.go4expert.com/forums/printint-2-d-array-t10113/)

cyrow 18Apr2008 17:21

Printint 2-d Array
 
Code:

import java.io.*;
import java.util.*;


//Print all the elements below the leading diagonal as zeros(The leading diagnol is where all the row index equal the column index.

class Printsqu{
        public static void main(String[] args){
        int [][]array = {
                                       
                                        {1,1,1,1},
                                        {1,1,1,1},
                                        {1,1,1,1},
                                        {1,1,1,1},
        };
       
                        for(int i = 0; i < array.length; i++){
                                for(int j = 0 ; j <array[i].length; j++){               
                                        System.out.print(array[i][j]);
                               
                        }
                        System.out.println();
                }               
        }//main
}//end method

Problem
I am trying to print the 4x4 array above with the digits below the diagnol (intersection of the rows and cols) zero. I am having some problems with the logic. When I write the data out I can see certain things, but when I code it, it just does not work? Any ideas?
________________________________________


All times are GMT +5.5. The time now is 18:06.