Working with a List of Lists in Java

I’m trying to read a CSV file into a list of lists (of strings), pass it around for getting some data from a database, build a new list of lists of new data, then pass that list of lists so it can be written to a new CSV file. I’ve looked all over, and I can’t seem to find an example on how to do it.

I’d rather not use simple arrays since the files will vary in size and I won’t know what to use for the dimensions of the arrays. I have no issues dealing with the files. I’m just not sure how to deal with the list of lists.

Most of the examples I’ve found will create multi-dimensional arrays or perform actions inside the loop that’s reading the data from the file. I know I can do that, but I want to write object-oriented code. If you could provide some example code or point me to a reference, that would be great.

Leave a Comment