-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathMethodReferenceEx2.java
More file actions
28 lines (21 loc) · 638 Bytes
/
MethodReferenceEx2.java
File metadata and controls
28 lines (21 loc) · 638 Bytes
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
package com.zetcode;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
public class MethodReferenceEx2 {
public static void main(String[] args) {
List<String> words = new ArrayList<>();
words.add("forest");
words.add(null);
words.add("falcon");
words.add("eagle");
words.add("rock");
words.add(null);
words.add("sky");
words.add("cloud");
words.forEach(System.out::println);
words.removeIf(Objects::isNull);
System.out.println("Null values removed:");
words.forEach(System.out::println);
}
}