/******************************************************************************
 * Example of 2 dimensional array
 *    with second dimensions having a different lengths
 ******************************************************************************/
public class array3
{
    public static void main (String[] args) 
    {

    //------ Multiplication table with 10 rows and 10 columns --------------

        int[ ][ ] mult = new int[10][10];               //declare a 2 dim array
    
        for (int i=0; i < mult.length; i++)             //loop thru rows
        {
            for (int j=0; j < mult[i].length; j++)      //loop thru cols
            {
                mult[i][j] = (i+1) * (j+1);             //multiply row+1 * col+1
                System.out.print(mult[i][j] + "\t");    //print it
            }
            System.out.println();             
        }

        System.out.println();


    //------ Multiplication table with random rows and columns --------------

        int[ ][ ] mult2;                                //declare a 2 dim array

        int rows = (int) (Math.random() * 10 +1);       //random rows size 1-10
    
        mult2 = new int[rows][];                        //allocate row dimension
    
        for (int i=0; i < mult2.length; i++)            //loop thru rows
        {
            int cols = (int) (Math.random() * 10 +1);   //random cols size 1-10

            mult2[i] = new int[cols];                   //allocate col dimension

            for (int j=0; j < mult2[i].length; j++)     //loop thru cols
            {
                mult2[i][j] = (i+1) * (j+1);            //multiply row+1 * col+1
                System.out.print(mult2[i][j] + "\t");   //print it
            }
            System.out.println();             
        }
    }
}