Java Streams

Stream pipelines as a design decision: when a stream is clearer than a loop and when it is not, side-effect-free stages and mutable reduction with collectors, the toMap and groupingBy traps, Collection versus Stream as a return type, streams that hold an open resource, parallel streams and the shared common pool, and Gatherers for custom intermediate operations. Use when a pipeline mutates state outside itself or uses forEach to accumulate, when Collectors.toMap throws IllegalStateException or NullPointerException, when a method returns a Stream that callers iterate twice, when a stream over Files.lines or a JDBC cursor is never closed, when parallelStream() appears — especially with blocking I/O — or when a loop is being rewritten as a stream for its own sake. Does not cover lambda capture and functional interfaces (java-lambdas-and-functional-interfaces), ForkJoinPool internals (forkjoinpool-and-work-stealing), or collection choice and complexity.

robsonkades 8ceb3ac 4 files · 27.6 KB Updated

File contents

robsonkades/agent-skills/tree/main/skills/java-streams commit 8ceb3acb1b

Frequently asked questions

npx skillmds@latest add robsonkades/java-streams