posted 13 years ago
Hey all,
Let's say I want to make a grid of x length on each side (like, say, a chessboard), in its own class. I don't know yet how long the grid has to be on each side - that'll depend on user input. I do know that once created the grid will keep its size.
I'd like to know if it's possible to do this as an array of arrays. If the size of the grid is known beforehand it's easy enough (Array[length][length]), but whenever I try to make a constructor that takes the length variable from another class, it complains that I can't use a dynamic reference to something static. Fair enough - but is there a way around this?
The other alternative I know of is to make an ArrayList, but there I run into the problem that I can't seem to wrap my head around creating an ArrayList of ArrayLists through a for-loop.