Java Streams - DoubleStream of(double... values) example








DoubleStream of(double... values) creates a sequential ordered stream whose elements are the specified values.

Syntax

of has the following syntax.

static DoubleStream of(double... values)

Example

The following example shows how to use of.

import java.util.stream.DoubleStream;
/*ww w  .  ja  va 2 s .  co  m*/
public class Main {
  public static void main(String[] args) {
    DoubleStream d = DoubleStream.of(1.2,2.3,4.5);
    
    d.forEach(System.out::println);
    
  }
}

The code above generates the following result.