Files
java-core-examples/streams/output/09-looptostream.txt
T

18 lines
609 B
Plaintext

== 1. The straightforward conversion ==
loop : {IN=1200.0, US=2300.0}
stream : {IN=1200.0, US=2300.0}
equal : true
== 2. A loop with break becomes findFirst, not filter ==
loop : ankur/laptop
stream : ankur/laptop
== 3. The list a loop built was mutable; toList() is not ==
loop list after add : [ankur, alex, brian, ankur, extra]
stream list after add : UnsupportedOperationException
== 4. A loop can update a counter; a lambda cannot ==
works, but it is a side effect: 2
the pipeline way (count) : 2
(a plain `int hits` would not compile: lambdas capture effectively-final variables only)