I have an ArrayList object to which I want to dynamically add ArrayLists.
However, since the compiler doesn't know what objects are going to be inside the outer ArrayList before the loop to add them runs, I can't use the inner ArrayLists as I normally would.
My code looks somewhat like this:
ArrayList list = new ArrayList();
for(int i=8;i>0;i--)
{
list.add(i, new ArrayList());
}
for(int i=8;i>0;i--)
{
tileRows.get(i).add( //add other stuff );
}
How can I tell the compiler that the items in list
are going to be of ArrayList
type?
Bear in mind that I'm completely new to Java. If this is a stupid question I apologise.