JAVA 16 / CATATAN</>↗Java 1626 Okt 2025
In Java, a LinkedHashMap is a subtype of HashMap that maintains a predictable iteration order. It uses a doubly linked list to store the entries in insertion order (or, optionally, access order). Here’s how you can use LinkedHashMap for predictable iteration order: 1. Maintaining Insertion Order By default, a LinkedHashMap iterates its entries in the […]
SOUND API / CATATAN</>↗Sound API25 Okt 2025
The Collectors.groupingBy is a powerful method in Java’s Stream API that allows grouping of elements in a stream based on a classification function, and it works well with downstream collectors. Here’s how you can use Collectors.groupingBy with downstream collectors effectively. Syntax of Collectors.groupingBy with a Downstream Collector The key method signature is: Collectors.groupingBy(Classifier, Downstream) Classifier: […]
JAVA / CATATAN{ }↗Java25 Okt 2025
The Stream.ofNullable method in Java is a utility introduced in Java 9. It is used to create a stream from an object that may or may not be null. This is especially useful when dealing with optional values where you want to avoid manually checking if a value is null before creating a stream. Here’s […]
JAVA / CATATAN{ }↗Java24 Okt 2025
In Java, the Map.copyOf() method, introduced in Java 10, is a factory method used to create an unmodifiable (immutable) copy of a given Map. This method ensures that the resulting Map cannot be modified, and attempting to do so throws an UnsupportedOperationException. Here’s how to use it effectively: Syntax: public static <K,V> Map<K,V> copyOf(Map<? extends […]
JAVA / CATATAN{ }↗Java24 Okt 2025
Collectors.flatMapping is a utility method in the java.util.stream.Collectors class (introduced in Java 9) that combines the concepts of flattening a collection of collections and mapping elements into a single flattened stream of results. Definition Collectors.flatMapping allows you to apply a mapping function to elements of a stream and simultaneously flatten the resulting streams (or collections) […]
JAVA / CATATAN{ }↗Java23 Okt 2025
To create infinite streams in Java using Stream.iterate, you can leverage its ability to generate elements lazily and indefinitely. Here’s a concise explanation: How to Create Infinite Streams with Stream.iterate The Stream.iterate method generates a stream by iterating a seed value (starting point) and applying a unary operator (function) to produce the next element. Key […]