My Other Blogs

http://myworld24x7.blogspot.com - This blog will have all the information about health especially skin and hair. you can know lot

Java 8 example – Filter a null value from a Stream


import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Java8Examples {

public static void main(String[] args) {

Stream<String> language = Stream.of("java", "python", "node", null, "ruby", null, "php");

//List<String> result = language.collect(Collectors.toList());

List<String> result = language.filter(x -> x!=null).collect(Collectors.toList());

result.forEach(System.out::println);


}
}
Output
 java python node ruby php