Reputation: 2205
This can be very basic question ... I am working with Java. I am parsing a file in one of my classes. Each line in the file has 3 arguments (currently). I want to use one generic collection to store all the values at once
something like List<String, String, String (and more args if needed)> list = new ....
. The number of arguments might increase later.
I am creating arrays right now to separate out individual args but that is not a proper solution. How can I declare a collection like that?
Upvotes: 0
Views: 59
Reputation: 878
use List<List<String>>
Using above collection you can have a List<String>
on each index of the List
.
To summarize it:
Each List<String>
will correspond to a line in that file
and List<List<String>>
will correspond to the entire file
Upvotes: 1