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 825 Jan 2024

How do I use Map.getOrDefault() default method in Java?

The Map.getOrDefault(Object key, V defaultValue) method in Java 8 is a convenience default method to return the value for a given key. If the map does not contain a mapping for the key, then it returns the default value. This method can be particularly useful in situations where you’re working with a map and need […]

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

How do I sort entries of a map by its keys or values?

To sort the entries of a map by keys or values in Java, you can convert your Map to a Stream, sort it, and then collect it back into a Map. Here’s an example of sorting by keys: package org.kodejava.util; import java.util.HashMap; import java.util.Map; import java.util.LinkedHashMap; import java.util.stream.Collectors; public class MapSortComparingByKey { public static void […]

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

How do I use the Map.forEach() default method?

The forEach() method in the Map interface in Java 8, allows you to iterate over each entry in the map, allowing you to use each key-value pair in some way. Here’s a basic usage of the forEach() method: package org.kodejava.util; import java.util.HashMap; import java.util.Map; public class MapForEachExample { public static void main(String[] args) { Map<String, […]

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

How do I use the List.sort() method?

The List.sort() method was introduced in Java 8. This method sorts the elements of the list on the basis of the given Comparator. If no comparator is provided, it will use the natural ordering of the elements (only if the elements are Comparable). Let’s take a look at an example where we sort a list […]

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

How do I use List.replaceAll() method?

The List.replaceAll() method was introduced in Java 8. This method replaces each element of the list with the result of applying the operator to that element. The operator or function you pass to replaceAll() should be a UnaryOperator. Here is a simple example: package org.kodejava.util; import java.util.ArrayList; import java.util.List; import java.util.function.UnaryOperator; public class ListReplaceAllExample { […]

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

How do I use Collection.removeIf() method?

The Collection.removeIf() method was introduced in Java 8, and it allows for the removal of items from a collection using a condition defined in a lambda expression. The primary purpose of the Collection.removeIf() method in Java is to filter out elements from a collection based on a certain condition or predicate. It’s a more efficient […]

Wayan · 3 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.