Skip to content

Commit d9ff9e3

Browse files
committed
update Java 9 examples
1 parent 1d3754d commit d9ff9e3

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.github.wesleyegberto.collections.collections;
2+
3+
import java.util.List;
4+
import java.util.stream.IntStream;
5+
import java.util.stream.Stream;
6+
7+
import static java.util.stream.Collectors.filtering;
8+
import static java.util.stream.Collectors.toList;
9+
10+
public class StreamTest {
11+
public static void main(String[] args) {
12+
Stream shouldBeEmpty = Stream.ofNullable(null);
13+
14+
// Won't print anything
15+
shouldBeEmpty.forEach(System.out::println);
16+
17+
List<Integer> numbers = IntStream.range(0, 10)
18+
.mapToObj(i -> Integer.valueOf(i))
19+
.collect(filtering(i -> i.intValue() > 5, toList()));
20+
21+
numbers.forEach(System.out::println);
22+
}
23+
}

java-9/others-features/src/main/java/com/github/wesleyegberto/collections/processapi/ProcessTest.java

+3-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ public static void main(String[] args) throws IOException, InterruptedException
1212
System.out.println("Sleepy pid: " + sleepy.pid());
1313

1414
System.out.println("Destroying sleepy");
15-
sleepy.onExit()
15+
ProcessHandle handle = ProcessHandle.of(sleepy.pid()).get();
16+
handle.onExit()
17+
// sleepy.onExit()
1618
.thenRun(() -> {
1719
System.out.println("Alive: " + sleepy.isAlive());
1820
System.out.println("Exit code: " + sleepy.exitValue());

0 commit comments

Comments
 (0)