Java Stream FilterJava stream provides a method filter() to filter stream elements on the basis of given predicate. Suppose you want to get only even elements of your list then you can do this easily with the help of filter method. This method takes predicate as an argument and returns a stream of consisting of resulted elements. SignatureThe signature of Stream filter() method is given below: Parameterpredicate: It takes Predicate reference as an argument. Predicate is a functional interface. So, you can also pass lambda expression here. ReturnIt returns a new stream. Java Stream filter() exampleIn the following example, we are fetching and iterating filtered data. Output: 90000.0 Java Stream filter() example 2In the following example, we are fetching filtered data as a list. Output: [90000.0] Next TopicJava Base64 Encode Decode |