**DoubleStream boxed()** returns a Stream consisting of the elements of this stream, each boxed to a Double.

**Note : **DoubleStream boxed() is a * intermediate operation.* These operations are always lazy. Intermediate operations are invoked on a Stream instance and after they finish their processing, they give a Stream instance as output.

**Syntax :**

Stream<Double> boxed()

**Parameters : **

**Stream :**A sequence of elements supporting sequential and parallel aggregate operations.**Double :**The Double class wraps a value of the primitive type double in an object. An object of type Double contains a single field whose type is double.

**Return Value : **The function returns a Stream boxed to a Double.

**Example 1 :**

`// Java code for DoubleStream boxed() ` `import` `java.util.*; ` `import` `java.util.stream.Stream; ` `import` `java.util.stream.DoubleStream; ` ` ` `class` `GFG { ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `// Creating an DoubleStream ` ` ` `DoubleStream stream = DoubleStream.of(` `3.2` `, ` `8.4` `, ` `3.6` `, ` `4.7` `); ` ` ` ` ` `// Creating a Stream of Doubles ` ` ` `// Using DoubleStream boxed() to return ` ` ` `// a Stream consisting of the elements ` ` ` `// of this stream, each boxed to a Double. ` ` ` `Stream<Double> stream1 = stream.boxed(); ` ` ` ` ` `// Displaying the elements ` ` ` `stream1.forEach(System.out::println); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

Output :

3.2 8.4 3.6 4.7

**Example 2 :**

`// Java code for DoubleStream boxed() ` `import` `java.util.*; ` `import` `java.util.stream.Stream; ` `import` `java.util.stream.DoubleStream; ` ` ` `class` `GFG { ` ` ` ` ` `// Driver code ` ` ` `public` `static` `void` `main(String[] args) ` ` ` `{ ` ` ` `// Creating an DoubleStream ` ` ` `DoubleStream stream = DoubleStream.of(` `3.2` `, ` `8.4` `, ` `3.6` `, ` `4.7` `); ` ` ` ` ` `// Creating a Stream of Doubles ` ` ` `// Using DoubleStream boxed() to return ` ` ` `// a Stream consisting of the elements ` ` ` `// of this stream, each boxed to a Double. ` ` ` `Stream<Double> stream1 = stream.boxed(); ` ` ` ` ` `Stream<Object> stream2 = Stream.concat(stream1, ` ` ` `Stream.of(` `"Geeks"` `, ` `"for"` `, ` `"Geeks"` `)); ` ` ` ` ` `// Displaying the elements ` ` ` `stream2.forEach(System.out::println); ` ` ` `} ` `} ` |

*chevron_right*

*filter_none*

Output :

3.2 8.4 3.6 4.7 Geeks for Geeks

Attention reader! Don’t stop learning now. Get hold of all the important Java and Collections concepts with the **Fundamentals of Java and Java Collections Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- IntStream boxed() in Java
- LongStream boxed() in Java
- Program to convert Boxed Array to Stream in Java
- DoubleStream noneMatch() in Java with examples
- DoubleStream distinct() in Java with examples
- DoubleStream count() in Java with examples
- DoubleStream min() in Java with examples
- DoubleStream max() in Java with examples
- DoubleStream average() in Java with Examples
- DoubleStream filter() in Java with examples
- DoubleStream empty() in Java with examples
- DoubleStream peek() in Java with examples
- DoubleStream anyMatch() in Java with examples
- DoubleStream allMatch() in Java with examples
- DoubleStream reduce(double identity, DoubleBinaryOperator op) in Java with Examples
- DoubleStream limit() in Java with Examples
- DoubleStream builder() in Java with Examples
- DoubleStream.Builder add(double t) in Java with Examples
- DoubleStream findFirst() with examples
- DoubleStream findAny() with examples

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.