
filter(str -> str.length() > 6 & str.length() num = Arrays. In the following example, we have two conditions in the filter method joined using and (&) logical operator. Whether you need side stream filtration for your hospital, school, or industrial facility, our specialized heat exchanger reduces water temperatures efficiently. With our modular design, you can tack on add-ons and fit it through doorways. We can have more than one conditions in the filter() method joined using the logical operators in java. Side stream filtration is the best way to maintain safety and efficiency. In the above examples we have seen that there is only one condition in the filter() method. Joffery Example 2: Stream filter() with multiple conditions collect(Collectors.toList()) // collect the final stream and convert it to a List filter(str -> str.length() > 6) // filter the stream to create a new stream List longnames = names.stream() // converting the list to stream The collect() method here collects the final stream and converts it into a list import We can create a stream and apply a filter in a one line as shown in the example below. Lets take few more examples of Java stream filter. Stream longNames = allNames.filter(str -> str.length() > 6) Creating another stream by filtering long names using filter() List names = Arrays.asList("Melisandre","Sansa","Jon","Daenerys","Joffery") As I mentioned above, the stream filter transforms the data of one stream into another stream. In this example we are creating a stream from the list of names using stream() method and then we are creating another stream of long names using stream filter(). Lets take a simple example first and then we will see the examples of stream filter with other methods of the stream. The filter() is an intermediate operation that reads the data from a stream and returns a new stream after transforming the data based on the given condition. In this guide, we will discuss the Java stream filter. I would recommend you to read that guide before going through this tutorial.

In the previous tutorial, we learned about Java Stream.
