SupportWriter space ↗
REFERENCE LIBRARY

References from other publishers

Republished articles with source attribution. This collection is separate from Diary Coding’s original guides and does not display ads.

Read original guides → · Editorial policy

FOR YOUR CURIOSITY

Latest notes.

JAVA 8 / NOTES</>↗
Java 810 Jan 2024

What is the peek method in Java Stream API and how to use it?

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 […]

Wayan · 2 min read
JAVA 8 / NOTES</>↗
Java 810 Jan 2024

How do I use map, filter, reduce in Java Stream API?

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 […]

Wayan · 4 min read
JAVA 8 / NOTES</>↗
Java 809 Jan 2024

How do I handle exceptions in Stream.forEach() method?

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; […]

Wayan · 3 min read
JAVA 8 / NOTES</>↗
Java 809 Jan 2024

How do I loop through streams using forEach() method?

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 […]

Wayan · 2 min read
JAVA 8 / NOTES</>↗
Java 808 Jan 2024

How do I create ranges of numbers as Streams?

In Java, you can use IntStream, LongStream, or DoubleStream to create ranges of numbers as streams. For example, to create a range of integer numbers, we can call the range() static method of the IntStream interface. Here’s an example: package org.kodejava.util; import java.util.stream.IntStream; public class IntRangeExample { public static void main(String[] args) { IntStream.range(1, 11).forEach(System.out::println); […]

Wayan · 3 min read
JAVA 8 / NOTES</>↗
Java 808 Jan 2024

How do I use Stream.iterate() method?

The Stream.iterate() method in Java is used to generate a Stream of elements based on some iterative logic. The simplest form Stream.iterate(initialValue, lambdaFunction) takes in an initial value and a UnaryOperator function to compute the next element in the series. Here’s an example of using `Stream.iterate()“ to create a Stream of incremental numbers: package org.kodejava.util; […]

Wayan · 2 min read
✳

Knowledge grows when shared.

Stay curious. There is always something new to learn.

Explore notes ↗
Putu Adi Guna Permana
ABOUT THE AUTHOR

Dr (C). Ir. Putu Adi Guna Permana, S.Kom., M.Kom., IPM., ASEAN Eng.

Writer and founder of Diary Coding — sharing notes, tutorials, and experiences about programming for anyone who wants to keep learning.