All Stories published by Javarevisited on March 17, 2023

Method References in Java8

Method references provide a shorthand notation for lambda expressions that only call a single method. Method references can be used to simplify the code and make it more readable. In this answer, we’ll explore the different types of method references in Java 8 with examples.


Non terminal operation peek() in Java8

In Java 8, the peek method is a non-terminal operation that allows you to perform an action on each element of a stream as it passes through the pipeline. It can be useful for debugging or logging, or for performing some kind of side effect on the stream…


Immutable class in java

We can create immutable classes by following these guidelines:

  1. Declare the class as final, so it cannot be subclassed.
  2. Make all fields private and final, so they cannot be modified after initialization.

About
Javarevisited
A humble place to learn Java and Programming better.
More information
Tags
Editors
Writers