posted 10 years ago
What’s a 2D list? Is there such a thing? I think there isn’t, only a List of Lists.
What’s a 2D array? Is there such a thing? I think there isn’t, only an array of arrays.
That may appear pedantic, but arrays of arrays are better than 2D arrays. For example, the outermost array has a length field, which you doubtless already know about. And the element arrays also have a length field. So you can iterate the outer array with a for‑each loop and check that all the lengths are the same.
You can do the same sort of thing with the size() method of your Lists. It might be quicker to do that validation at as early a stage as possible.