Skip to main content

Can you improve the performance of the stream filter code

Can you improve the performance of  the Stream filter code below?

private static LinkedList<Integer> ll;
private static void filterQ() {
    ll = new LinkedList<>();
    IntStream.range(0, 100).forEach((i) -> ll.add(i));
    ll =  ll.stream().filter((i) -> i != 10 )
           .collect( Collectors.toCollection(LinkedList::new) );
}

You can find the answer here

Comments