File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
core-java/src/test/java/org/baeldung/java/collections Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change 44import static org .junit .Assert .assertThat ;
55
66import java .util .ArrayList ;
7+ import java .util .Collections ;
78import java .util .HashSet ;
89import java .util .List ;
910
@@ -29,6 +30,14 @@ public final void givenListContainsNulls_whenRemovingNullsWithPlainJava_thenCorr
2930 assertThat (list , hasSize (1 ));
3031 }
3132
33+ @ Test
34+ public final void givenListContainsNulls_whenRemovingNullsWithPlainJavaAlternative_thenCorrect () {
35+ final List <Integer > list = Lists .newArrayList (null , 1 , null );
36+ list .removeAll (Collections .singleton (null ));
37+
38+ assertThat (list , hasSize (1 ));
39+ }
40+
3241 @ Test
3342 public final void givenListContainsNulls_whenRemovingNullsWithGuavaV1_thenCorrect () {
3443 final List <Integer > list = Lists .newArrayList (null , 1 , null );
You can’t perform that action at this time.
0 commit comments