The Streams API provides min() and max() methods—stream processing for finding the minimum or maximum value in the stream respectively.
Let's take an example in the context of the sample application we're testing. We will create a simple Java class called Product that stores the name and price of products returned by the search. We want to find the product that has the minimum price and the one that has the maximum price. Our product class will have two members, as shown in the following code:
class Product { String name; Double price; public Product(String name, double price) { this.name = name; this.price = price; } public String getName() { return name; } public Double getPrice() { return price; }}
Let's create ...