JAVA 8 / CATATAN</>↗Java 810 Jan 2024
The limit(long maxSize) method in Java’s Stream API is used for reducing the size of the stream. It takes a single parameter, maxSize, which is a long value that represents the maximum number of elements that the stream should be limited to. The primary purpose and usefulness of the limit() method can be summarized as […]
SOUND API / CATATAN</>↗Sound API10 Jan 2024
The Java Sound API is a feature of the Java platform, designed to provide low-level support for audio operations such as audio playback and capture (recording), audio format conversions, and sequencing and synthesizing of MIDI (Musical Instrument Digital Interface) Overview Java Sound API, included in the Java SE (Standard Edition), is a powerful and flexible […]
JAVA 8 / CATATAN</>↗Java 810 Jan 2024
The peek method in Java’s Stream API is an intermediary operation. This method provides a way to inspect the elements in the stream as they’re being processed by other stream operations. However, it’s important to note that peek should only be used for debugging purposes, as it can be quite disruptive to the stream’s data […]
JAVA 8 / CATATAN</>↗Java 810 Jan 2024
The map(), filter(), and reduce() methods are key operations used in Java Stream API which is used for processing collection objects in a functional programming manner. Java Streams provide many powerful methods to perform common operations like map, filter, reduce, etc. These operations can transform and manipulate data in many ways. map: The map() function […]
JAVA 8 / CATATAN</>↗Java 809 Jan 2024
When using Java’s Stream.forEach() method, you might encounter checked exceptions. Checked exceptions can’t be thrown inside a lambda without being caught because of the Consumer functional interface. It does not allow for this in its method signature. Here is an example of how you might deal with an exception in a forEach operation: package org.kodejava.basic; […]
JAVA 8 / CATATAN</>↗Java 809 Jan 2024
In Java, you can loop through a Stream by using the forEach() method provided by the Stream API. In the following example, we created a Stream of Strings. Each String represents a different programming language. The forEach() method accepts a Consumer, which is a functional interface representing an operation that accepts a single input argument […]