Java Streams - DoubleStream of(double t) example








DoubleStream of(double t) creates a sequential DoubleStream containing a single element.

Syntax

of has the following syntax.

static DoubleStream of(double t)

Example

The following example shows how to use of.

import java.util.stream.DoubleStream;
/*from w ww .  ja  v a 2 s  .  c o  m*/
public class Main {
  public static void main(String[] args) {
    DoubleStream d = DoubleStream.of(1.2);
    
    d.forEach(System.out::println);
    
  }
}

The code above generates the following result.