Assignment 5
Assignment 5
PROGRAM
import java.util.*;
import java.util.stream.Collectors;
class Product {
this.name = name;
this.category = category;
this.price = price;
return name;
return category;
}
return price;
@Override
return "Product{name='" + name + "', category='" + category + "', price=" + price + "}";
);
.collect(Collectors.toList());
.mapToDouble(Product::getPrice)
.sum();
.max(Comparator.comparingDouble(Product::getPrice))
.orElseThrow(NoSuchElementException::new);
.map(Product::getName)
.sorted()
.collect(Collectors.toList());