Skip to content

Commit 2e5ba7a

Browse files
authored
Create MethodReferenceEx2.java
1 parent a884d2a commit 2e5ba7a

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

‎lambda/MethodReferenceEx2.java‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.zetcode;
2+
3+
import java.util.ArrayList;
4+
import java.util.List;
5+
import java.util.Objects;
6+
7+
public class MethodReferenceEx2 {
8+
9+
public static void main(String[] args) {
10+
11+
List<String> words = new ArrayList<>();
12+
words.add("forest");
13+
words.add(null);
14+
words.add("falcon");
15+
words.add("eagle");
16+
words.add("rock");
17+
words.add(null);
18+
words.add("sky");
19+
words.add("cloud");
20+
21+
words.forEach(System.out::println);
22+
23+
words.removeIf(Objects::isNull);
24+
25+
System.out.println("Null values removed:");
26+
words.forEach(System.out::println);
27+
}
28+
}

0 commit comments

Comments
 (0)