Switch to full style
General Java code examples
Post a reply

Uneven rows-2-dimenstionals-triangle look like 2D array

Tue Jul 24, 2012 4:07 pm

creating a 2-dimenstionals array with number of columns differs at each row, The output will be a triangle look like array :

Code:

    int
[][] arrayNotBalanced = new int[10][];   
        
        for 
(int i = 0; i < arrayNotBalanced.length; i++) {
            arrayNotBalanced[i] = new int[+ 1];
        }


        // printing the rectangle array
        for (int i = 0;< arrayNotBalanced.length; i++) {
            for (int j = 0; j < arrayNotBalanced[i].length; j++) {
                System.out.print(" " + arrayNotBalanced[i][j]);
            }
            System.out.println("");
        }
 


output:
Code:
0
0 0
0 0 0
0 0 0 0
0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0




Post a reply
  Related Posts  to : Uneven rows-2-dimenstionals-triangle look like 2D array
 Randomly generated rows and columns in Array     -  
 Triangle of stars (C++)     -  
 pascal triangle     -  
 Draw Triangle using Lines     -  
 Drawing a triangle with colors     -  
 Java Programming Problem: Pascal's Triangle     -  
 three rows frameset .     -  
 Get affected rows for an update in php     -  
 Select odd rows from table     -  
 different colors for table Even- Odd rows and Cells     -  

Topic Tags

Java Arrays