Java Streams - LongStream of(long t) example








LongStream of(long t) returns a sequential LongStream containing a single element.

Syntax

of has the following syntax.

static LongStream of(long t)

Example

The following example shows how to use of.

import java.util.stream.LongStream;

public class Main {
  public static void main(String[] args) {
    LongStream b = LongStream.of(1L);

    b.forEach(System.out::println);
  }
}

The code above generates the following result.