in order to create an array of ArrayLists. I'm being met with the following compilation error:
ArrayList<Object> arr; arr = new ArrayList<Object>()[size];
generates the compiler error: "generic array creation" (generics and arrays don't play well together)
List<Object> arr = new ArrayList<Object>;
Me? I don't like mixing arrays and collections. I would have a list of lists:
List arr = new ArrayList;
List<List<X>> matrix = new ArrayList<List<X>>();
CeciNEstPasUnProgrammeur wrote:I concede your point about defining a class versus creating multidimensional structures, but I still reach for collections first, over arrays, unless I know it's going to be so simple that an array must suffice.
I on the other hand prefer arrays wherever I can, and when confronted with lists of lists or arrays of arrays I wonder whether there should actually be another class for that.