LongStream builder() method in Java

Java 8Object Oriented ProgrammingProgramming

The LongStream builder() class in Java is used to return a builder for a LongStream.

The syntax is as follows.

static LongStream.Builder builder()

Here, LongStream.Builder is a mutable builder for a LongStream.

To use the LongStream class in Java, import the following package.

import java.util.stream.LongStream;

The following is an example to implement LongStream builder() method in Java.

Example

 Live Demo

import java.util.stream.LongStream;
public class Demo {
   public static void main(String[] args) {
      LongStream longStream = LongStream.builder().add(5).build();
      longStream.forEach(System.out::println);
   }
}

Output

5
raja
Published on 27-Mar-2019 10:58:55
Advertisements