Q:

How can I access the array(2-d) added to ArrayList?

How can I access the 2D arrays added to an ArrayList?
import java.util.*;
class Input
{
   public static void main(String args[])
   {
       ArrayList arr=new ArrayList();
       int x;
       System.out.println("enter no of arrays");
       Scanner sc=new Scanner(System.in);
       x=sc.nextInt();
       int c=1;
       while(c<=x)
       {
         System.out.println("enter a case:");
         int[][] ch=new int[4][4];
         for(int i=0;i<4;i++)
         {
           System.out.println();
           for(int j=0;j<4;j++)
           {
             ch[i][j]=sc.nextInt();
           }
         }
         arr.add(ch);
         c++;
       }
   }
}

A:

Parametrize the ArrayList:
ArrayList<int[][]> arr = new ArrayList<int[][]>();

Then you can simply access the elements as int[][]s via get().

A:

Specify a type for the ArrayList:
ArrayList<int[][]> arr;

Then arr.get(index) will correctly be treated as an int[][].

