Is it possible to combine the creation of a List
of String[]
with the initialization of the first entry in the List
?
final List<String[]> rolesCsv = new ArrayList<String[]>();
rolesCsv.add(new String[] {"Role Name","Description"});
In other words, can I combine the above two lines into a single one that both creates and initializes the List
?
The List<String[]>
does need to be mutable for later adding to the List
, yes.
IMPORTANT NOTE for EDITORS: Creating and initializing this definition is far different than solutions for simply creating and initializing List<String>
- BEFORE you automatically link this question to the common answers for the latter, please stop! The problem is different and requires a different solution.
>`?
– MC Emperor Jul 27 '21 at 18:58