I try to use java8 stream to parse a CSV file to a list which has 23000 elements.
csvAsList.stream().map(element -> transform(element)).collect(toList())
I look at toList()
source code:
public static <T> Collector<T, ?, List<T>> toList() {
return new CollectorImpl<>(
(Supplier<List<T>>) ArrayList::new, List::add, (left, right) -> { left.addAll(right); return left; },
CH_ID);
}
ArrayList::new
will use the default size.
But since the application will do lots of transformations like that. I think it's better to create an arraylist with a larger given size. It could save time by not copying the whole array again and again.
Is it doable? or is it just not worth doing?