import java.util.Scanner;
public class JaggedArray
{
public static void main(String args[ ])
{
Scanner s=new Scanner(System.in);
int x[ ] [ ]= new int[3][ ];
x[0]= new int[1];
x[1]= new int[2];
x[2]= new int[3];
int row, col;
System.out.println("Enter elements in jagged array ");
for(row=0;row<=2;row++)
{
for(col=0;col<=row; col++)
{
x[row][col]= s.nextInt();
}
}
System.out.println("Enter elements of jagged array =");
for(row=0;row<=2;row++)
{
for(col=0;col<=row; col++)
System.out.print(x[row][col]+"\t");
System.out.println();
}
}
}
Comments