Close

Java 8 Streams - DoubleStream.boxed Examples

Java 8 Streams Java Java API 


Interface:

java.util.stream.DoubleStream

java.lang.AutoCloseableAutoCloseablejava.util.stream.BaseStreamBaseStreamjava.util.stream.DoubleStreamDoubleStreamLogicBig

Method:

Stream<Double> boxed()

This intermediate operation returns a Stream consisting of the elements of this stream, each boxed to an Double.

Examples


package com.logicbig.example.doublestream;

import java.util.stream.DoubleStream;
import java.util.stream.Stream;

public class BoxedExample {

public static void main(String... args) {
DoubleStream doubleStream = DoubleStream.of(1.2, 1.3, 1.4, 1.5, 1.6);
Stream<Double> boxed = doubleStream.boxed();

Stream<String> stream = Stream.of("a", "b");
Stream<Object> concat = Stream.concat(boxed, stream);
concat.forEach(System.out::println);
}
}

Output

1.2
1.3
1.4
1.5
1.6
a
b




See Also