On 07/09/2015 01:10 PM, Pavel Rappo wrote:
On 9 Jul 2015, at 20:46, Remi Forax <fo...@univ-mlv.fr> wrote:
just to be complete , there is also
ArrayList<String> l = new ArrayList<>();
Collections.addAll(l, "1", "2", "3", "4", "5");
which avoid the allocation of the intermediary list.
Thanks Remi, I forgot about that. That's arguably the next best thing after
a per-type factory.
Would it make sense to have a version that returns the Collection to
further simplify the code?
Would probably require some work with generics to work nicely.
ArrayList<String> l = Collections.addAll(new ArrayList<>(), "1", "2", "3", "4",
"5");
//Staffan