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.
If you don't have all of the data in advance to be able to leverage aioobe's solution, you could use a Table from Google's Guava library.
Table matrix = new HashBasedTable();
matrix.put(rowIndex,columnIndex,value);
The primary drawback of this is that it's not incredibly fast or memory efficient if you are working with a large quantity of data, as everything is a hash lookup and primitives are wrapped by Integer.