CORE API / CATATAN</>↗Core API24 Feb 2025
The BiConsumer interface in Java is part of the java.util.function package and is used when we need to perform an operation that takes two input arguments and does not return any result. It is a functional interface commonly used in lambda expressions or functional programming scenarios. Key Features: It accepts two arguments of potentially different […]
CORE API / CATATAN</>↗Core API23 Feb 2025
The Predicate class in Java is a functional interface introduced in Java 8 under the java.util.function package. It is used to test a condition on an input and return a boolean value (true or false). Predicates are often used in lambda expressions or method references to filter data or apply conditional logic. Here’s how we […]
STREAM API / CATATAN</>↗Stream API06 Feb 2025
To add an object to the beginning of a list using Java Streams, we typically cannot directly prepend an object in a stream-friendly way because Streams themselves are immutable and don’t directly modify the original collection. However, we can achieve this by creating a new list with the desired order. Here’s how we can approach […]
JAVA DATE TIME API / CATATAN</>↗Java Date Time API07 Sep 2024
You can get the number of each day (Monday, Tuesday, etc.) for a specific month in Java using the java.time package introduced in Java 8. In the following code snippet we will use a loop to iterate the dates in the month. The number of loop is equals to the number of days in the […]
JAVA 9 / CATATAN</>↗Java 922 Jul 2024
Java 9 introduced the ProcessHandle API, which allows us to interact with and retrieve information about native processes. Here’s how we can use ProcessHandle to get information about operating system processes: We can list all the processes currently running on the system and print their details: package org.kodejava.example.lang; import java.time.Duration; import java.time.Instant; public class ProcessHandleExample […]
STREAM API / CATATAN</>↗Stream API21 Jul 2024
If we have a list of objects, and we want to sum a BigDecimal property of these objects, we can achieve this using the Java Stream API. This API provides a clean and efficient way to process collections of objects. To sum the BigDecimal amounts, you can use the map and reduce methods of the […]