Answer the question
In order to leave comments, you need to log in
Java: for on collection or functionality?
I have a piece of code (from a homemade game - because the planets).
for (Planet p : planets) {
st.print(p.prototype.code);
}
planets.stream().forEach((p) -> {
st.print(p.prototype.code);
});
Answer the question
In order to leave comments, you need to log in
Declarative-style programs tend to take up less space and are easier to read, that's all. You can also iterate through a collection in parallel by replacing stream() with parallelStream(), filter the elements you want with a predicate, and generally do a lot of useful things.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question