Java Stream Code To Ignore Null

Source URL: N/A

Language: java

Created on: 2021-01-20 23:41:26

List<String> result = Arrays.asList("Java", "Stream", null, "Filter", null);
result.stream().filter(str -> str != null).forEach(System.out::println)
// OR
Stream<String> result = Stream.of("java", null, "python", "devops", null);
result.filter(str -> str != null).forEach(System.out::println)
Java Stream Code To Ignore Null
content_copy