package com.logicbig.example.doublestream;
import java.util.stream.DoubleStream;
public class ForEachExample {
public static void main(String... args) {
System.out.println("-- sequential --");
DoubleStream ds = DoubleStream.of(1.0, 1.2, 2.0, 2.4, 3.0);
ds.forEach(System.out::println);
System.out.println("-- parallel --");
DoubleStream ds2 = DoubleStream.of(1.0, 1.2, 2.0, 2.4, 3.0);
ds2.parallel()
.forEach(System.out::println);
}
}
Output
-- sequential --
1.0
1.2
2.0
2.4
3.0
-- parallel --
2.0
3.0
1.2
1.0
2.4