I have to create a 2d array with unknown size. So I have decided to go with a 2d ArrayList the problem is I\'m not sure how to initialize such an array or store information.
import java.util.*;
public class ArrayListDS {
public static void main( String [] args ) {
ArrayList> row = new ArrayList>();
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of row: ");
int n = sc.nextInt();
for(int i = 0; i < n; i++){
ArrayList col = new ArrayList();
row.add(col);
System.out.println("Enter the number of column: ");
int m = sc.nextInt();
for(int j = 0; j < m; j++){
col.add(sc.nextInt());
}
System.out.println();
}
System.out.println(row);
}
}