DoubleStream boxed() method in Java


The boxed() method of the DoubleStream class returns a Stream consisting of the elements of this stream, boxed to Double.

The syntax is as follows

Stream<Double> boxed()

Here, Double is the class that wraps a value of the primitive type double in an object. To work with DoubleStream class in Java, import the following page

import java.util.stream.DoubleStream;

The following is an example to implement DoubleStream boxed() method in Java

Example

 Live Demo

import java.util.*;
import java.util.stream.Stream;
import java.util.stream.DoubleStream;
public class Demo {
   public static void main(String[] args) {
      DoubleStream doubleStream = DoubleStream.of(80.2, 84.6, 88.9, 92.9);
      Stream<Double> s = doubleStream.boxed();
      s.forEach(System.out::println);
   }
}

Output

80.2
84.6
88.9
92.9

Updated on: 30-Jul-2019

105 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements