Oh lol, my initial desire was to answer the "Lecturer's question" and create a list first, so the code was initially different.
It initially created a list, assigned it to a variable and then worked on it, but when I shortened the code I didn't bother on (I might have felt lazy :/) to remove the creation of an intermediate collection.
Thanks for the advice though.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
IntStream.rangeClosed(1, 10)
.filter(i -> i % 2 == 0)
.forEach(System.out::println);
Yes, thank you Armin. I should have mentioned I used a static import of IntStream, that's why I didn't use "IntStream'.
It's not about the static import (which is fine), it's the unnecessary creation of an intermediate collection.
Oh lol, my initial desire was to answer the "Lecturer's question" and create a list first, so the code was initially different.
It initially created a list, assigned it to a variable and then worked on it, but when I shortened the code I didn't bother on (I might have felt lazy :/) to remove the creation of an intermediate collection.
Thanks for the advice though.