<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Collections on Devops Monk</title><link>https://blog.devops-monk.com/tags/collections/</link><description>Recent content in Collections 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://blog.devops-monk.com/tags/collections/index.xml" rel="self" type="application/rss+xml"/><item><title>Collection Factory Methods (JEP 269): Immutable List, Set, and Map</title><link>https://blog.devops-monk.com/tutorials/java11/collection-factory-methods/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java11/collection-factory-methods/</guid><description>Why Collection Factory Methods? Before Java 9, creating a small immutable collection was tedious:
// Java 8 — three lines, two classes, mutable intermediate List&amp;lt;String&amp;gt; names = Collections.unmodifiableList( Arrays.asList(&amp;#34;Alice&amp;#34;, &amp;#34;Bob&amp;#34;, &amp;#34;Charlie&amp;#34;) ); // Java 8 — even worse for Map Map&amp;lt;String, Integer&amp;gt; scores = new HashMap&amp;lt;&amp;gt;(); scores.put(&amp;#34;Alice&amp;#34;, 90); scores.put(&amp;#34;Bob&amp;#34;, 85); Map&amp;lt;String, Integer&amp;gt; immutableScores = Collections.unmodifiableMap(scores); JEP 269 (Java 9) introduced static factory methods that create truly immutable collections with a single expression:</description></item><item><title>Collections and Map Enhancements: forEach, merge, compute, replaceAll</title><link>https://blog.devops-monk.com/tutorials/java8/collections-maps/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java8/collections-maps/</guid><description>Overview Java 8 didn&amp;rsquo;t just add Streams — it also enhanced the existing Iterable, Collection, List, and Map interfaces with default methods that cover the most common imperative patterns. Understanding these methods lets you write cleaner code even without streams.
The three methods worth memorising immediately are computeIfAbsent (the most useful new Map method), merge (for accumulation patterns), and removeIf (eliminating the iterator-based removal pattern). Together they eliminate the most common sources of verbose boilerplate in collection-heavy code.</description></item><item><title>Sequenced Collections (JEP 431): A Unified API for Ordered Collections</title><link>https://blog.devops-monk.com/tutorials/java21/sequenced-collections/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java21/sequenced-collections/</guid><description>The 30-Year Gap in the Collections API Java&amp;rsquo;s Collections Framework has a fundamental inconsistency: there is no uniform way to access the first or last element of an ordered collection. Before Java 21:
// List — index-based var list = List.of(&amp;#34;a&amp;#34;, &amp;#34;b&amp;#34;, &amp;#34;c&amp;#34;); String first = list.get(0); // first element String last = list.get(list.size() - 1); // last element — verbose, error-prone // Deque — special methods Deque&amp;lt;String&amp;gt; deque = new ArrayDeque&amp;lt;&amp;gt;(List.</description></item><item><title>Streams API: Lazy Pipelines and the Functional Data Model</title><link>https://blog.devops-monk.com/tutorials/java8/streams-introduction/</link><pubDate>Mon, 04 May 2026 00:00:00 +0000</pubDate><guid>https://blog.devops-monk.com/tutorials/java8/streams-introduction/</guid><description>The Problem Streams Solve Java loops are not wrong — they are often the right tool. But when a computation is a multi-step pipeline of filter → transform → aggregate, a loop hides the structure of the computation in a tangle of temporary variables and mutated collections. The Streams API makes the structure explicit, lets the JVM optimise it, and composes naturally with lambdas and method references.
Consider filtering a list of orders to find the names of active premium customers who spent over $500, sorted alphabetically:</description></item></channel></rss>