streams: Java Stream API + Collectors cookbook module (creation, laziness and short-circuiting, intermediate/terminal ops, Collectors recipes and toMap traps, primitive stream overflow, parallel traps, Gatherers on JDK 25, loop-to-stream conversion), 12 contract tests
Co-Authored-By: Claude Sonnet 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_017ic4b49nGy7tcEjVUa3WAA
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
== 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)
|
||||
Reference in New Issue
Block a user