Filter null values after map in Java 8 [duplicate]
问题 This question already has answers here : Filter values only if not null using lambda in Java8 (6 answers) Closed 4 years ago . I'm new in using map and filters in Java 8. I'm currently using Spark ML library for some ML algorithms. I have the following code: // return a list of `Points`. List<Points> points = getPoints(); List<LabeledPoint> labeledPoints = points.stream() .map(point -> getLabeledPoint(point)) .collect(Collectors.toList()); The function getLabeledPoint(Point point) returns a