Answers for "java stream code to ignore null"

0

java stream code to ignore null

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)
Posted by: Guest on January-20-2021

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language