Java Streams - DoubleStream boxed() example








DoubleStream boxed() returns a Stream boxed to Double. This is an intermediate operation.

Syntax

boxed has the following syntax.

Stream<Double> boxed()

Example

The following example shows how to use boxed.

import java.util.stream.DoubleStream;
import java.util.stream.Stream;
//from  w  w w.  j av  a 2  s. c o  m
public class Main {
  public static void main(String[] args) {
    DoubleStream i = DoubleStream.of(1.0,2.0,3.3,4.4,5.5,6.6,7.7);
    Stream<Double> o =  i.boxed();
    
    o.forEach(System.out::println);
  }
}

The code above generates the following result.