The program will give the following output

55 45 36

28 21


10 6

3 1 0

Now, I have managed to print only the followings:

55 45 36

28 21 // This line with some kind of error though it ran.

Now what should be the addtional codes to get the afformentioned

public class Task2 {

     * @param args the command line arguments
    public static void main(String[] args) {
        // TODO code application logic here
        int     a = 55,
        int [][] newArray=new int[5][];
        newArray[0]=new int[3];
        newArray[1]=new int[2];
        newArray[2]=new int[1];
        newArray[3]=new int[2];
        newArray[4]=new int[3];
        for(int row=0; row<5; row++){
            for(int col=0; col<3; col++){
            System.out.print(" " +newArray[row][col]);


Edited 5 Years Ago by peter_budo: Not snipped, changing to thread

Don't loop like this:

for(int row=0; row<5; row++){
for(int col=0; col<3; col++){

Always like this:

for(int row=0; row<array.length; row++){
for(int col=0; col<array[row].length; col++){
This article has been dead for over six months. Start a new discussion instead.