JAVA 9 / CATATAN</>↗Java 903 Nov 2025
In Java 9, the Collectors.filtering method was introduced to the Stream API as part of java.util.stream.Collectors. It allows you to apply a filter to elements of a stream before collecting them into a downstream collector (e.g., toList, toSet, etc.). This can be particularly useful when you want to filter elements as part of the data […]
STREAM API / CATATAN</>↗Stream API03 Nov 2025
Using the Optional.stream() method with flatMap is a common scenario when you want to work with collections and operations involving Optional. The Optional.stream() method converts an Optional value into a Stream, which will either contain the single value (if the Optional is present) or be empty (if the Optional is empty). This is particularly useful […]
BASIC / CATATAN</>↗Basic02 Nov 2025
Java 25 is the latest version of the Java Development Kit (JDK), packed with performance improvements and new features. In this guide, you’ll learn how to install Java 25 on your system and write your first “Hello, World!” program using the new classless main method feature. Tip: Java 25 introduces the ability to write simple […]
STREAM API / CATATAN</>↗Stream API01 Nov 2025
To parallelize a stream in Java and improve performance, you can use the parallelStream method or convert a normal stream into a parallel stream using the Stream.parallel() method. Parallel streams allow data to be processed on multiple threads, leveraging multicore processors. Here’s a detailed explanation and examples: 1. Using parallelStream() You can use the parallelStream() […]
STREAM API / CATATAN</>↗Stream API31 Okt 2025
The Stream.peek method in Java’s Stream API is an invaluable utility for debugging your stream pipeline. It provides a way to inspect (or “peek at”) the elements of your stream during the processing without modifying them. This is typically used for logging or debugging purposes. Here’s how Stream.peek works and how you can use it […]
UTIL PACKAGE / CATATAN</>↗Util Package30 Okt 2025
In Java, you can safely convert a List to a Map using Collectors.toMap by ensuring that duplicate keys or null values are handled appropriately. Here’s how you can achieve this: Safe Conversion Approach: When working with Collectors.toMap, it’s important to keep the following in mind: Handle Key Collisions: If multiple elements map to the same […]