-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrimitiveStreamsDemo.java
More file actions
30 lines (24 loc) · 1.03 KB
/
PrimitiveStreamsDemo.java
File metadata and controls
30 lines (24 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package Stream;
import java.util.Arrays;
import java.util.Random;
import java.util.stream.Collectors;
import java.util.stream.DoubleStream;
import java.util.stream.IntStream;
public class PrimitiveStreamsDemo {
static void main(String[] args) {
int[] numbers = {1, 2, 3, 4, 5};
IntStream stream = Arrays.stream(numbers);
System.out.println(IntStream.range(1, 5).boxed().collect(Collectors.toList()));
System.out.println(IntStream.rangeClosed(1, 5).boxed().collect(Collectors.toList()));
DoubleStream doubles = new Random().doubles(5);
// System.out.println(doubles.sum());
// System.out.println(doubles.min());
// System.out.println(doubles.max());
// System.out.println(doubles.average());
// doubles.summaryStatistics();
// IntStream intStream = doubles.mapToInt(x -> (int) (x + 1));
System.out.println(doubles.boxed().toList());
IntStream intStream2 = new Random().ints(5);
System.out.println(intStream2.boxed().toList());
}
}