- Which version of Java Streams API is introduced?
Java 8.
- Explain the filter function of Streams API.
Java Stream API provides a filter() method to filter stream elements on the basis of the given predicate. Suppose we want to get all the link elements that are visible on the page, we can use the filter() method to return the list in the following way:
List<WebElement> visibleLinks = links.stream()
.filter(item -> item.isDisplayed())
.collect(Collectors.toList());
- Which method of Streams API will return the number of matching elements from the filter() function?
count().
- We can use the map() function to filter a list of WebElements by attribute values: True or false?
False.