<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Streams on Devops Monk</title><link>https://devops-monk.com/tags/streams/</link><description>Recent content in Streams on Devops Monk</description><generator>Hugo</generator><language>en-us</language><lastBuildDate>Mon, 04 May 2026 00:00:00 +0000</lastBuildDate><atom:link href="https://devops-monk.com/tags/streams/index.xml" rel="self" type="application/rss+xml"/><item><title>Advanced Streams: flatMap, Collectors, Grouping, and Partitioning</title><link>https://devops-monk.com/tutorials/java8/streams-advanced/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://devops-monk.com/tutorials/java8/streams-advanced/</guid><description>flatMap in Depth flatMap is the most powerful transformation in the Streams API. It maps each element to a stream, then flattens all those streams into one continuous stream.
// Without flatMap — stream of lists Stream&amp;lt;List&amp;lt;String&amp;gt;&amp;gt; nested = Stream.of( Arrays.asList(&amp;#34;a&amp;#34;, &amp;#34;b&amp;#34;), Arrays.asList(&amp;#34;c&amp;#34;, &amp;#34;d&amp;#34;), Arrays.asList(&amp;#34;e&amp;#34;) ); // Stream&amp;lt;String&amp;gt;: &amp;#34;a&amp;#34;, &amp;#34;b&amp;#34;, &amp;#34;c&amp;#34;, &amp;#34;d&amp;#34;, &amp;#34;e&amp;#34; Stream&amp;lt;String&amp;gt; flat = nested.flatMap(Collection::stream); Practical flatMap Patterns Flatten orders into line items:
List&amp;lt;LineItem&amp;gt; allItems = orders.stream() .flatMap(order -&amp;gt; order.</description></item><item><title>Java 8 Best Practices and Patterns for Production Code</title><link>https://devops-monk.com/tutorials/java8/java8-best-practices/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://devops-monk.com/tutorials/java8/java8-best-practices/</guid><description>Streams Best Practices Do: Use streams for transformations and aggregations // Good: filter → transform → collect List&amp;lt;String&amp;gt; premiumNames = customers.stream() .filter(Customer::isPremium) .map(Customer::getName) .sorted() .collect(Collectors.toList()); // Good: aggregation Map&amp;lt;String, Long&amp;gt; countByCity = customers.stream() .collect(Collectors.groupingBy(Customer::getCity, Collectors.counting())); Don&amp;rsquo;t: Use streams for simple indexed iteration // Bad: stream for something a loop does more clearly IntStream.range(0, list.size()) .forEach(i -&amp;gt; System.out.println(i + &amp;#34;: &amp;#34; + list.get(i))); // Good: traditional loop wins here for (int i = 0; i &amp;lt; list.</description></item><item><title>Java 8 Overview: The Most Important Java Release Ever</title><link>https://devops-monk.com/tutorials/java8/java8-overview/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://devops-monk.com/tutorials/java8/java8-overview/</guid><description>Why Java 8 Matters Java 8 was released on 18 March 2014 — nearly three years after Java 7 — and it changed Java more fundamentally than any release before or since. For the first time, Java developers could write functional-style code natively, without external libraries or workarounds.
The headline features — lambda expressions and the Streams API — solved a problem that had frustrated Java developers for years: the verbosity of iteration.</description></item><item><title>Streams API: Lazy Pipelines and the Functional Data Model</title><link>https://devops-monk.com/tutorials/java8/streams-introduction/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://devops-monk.com/tutorials/java8/streams-introduction/</guid><description>The Problem Streams Solve Consider filtering a list of orders to find the names of active premium customers who spent over $500, sorted alphabetically:
// Java 7 List&amp;lt;String&amp;gt; result = new ArrayList&amp;lt;&amp;gt;(); for (Order order : orders) { if (order.isActive() &amp;amp;&amp;amp; order.isPremium() &amp;amp;&amp;amp; order.getTotal() &amp;gt; 500) { result.add(order.getCustomerName()); } } Collections.sort(result); This code is correct but reveals nothing about the structure of the computation at a glance. You have to read every line to understand what&amp;rsquo;s happening.</description></item></channel></rss>