You can simply use List<List<YourClass>> . Or even easier Map<Integer, List<YourClass>> compare the row number (first parameter, integer) with the string (second parameter, list of YourClass objects, List<YourClass> ) ... and build the DataModel class around this collection, which guarantees the possibility intersecting the same number of elements in each row (even if the row does not have all the elements, just returning zeros or empty objects or the like) by implementing a custom Iterator .
source share