Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static double totalPrice(int userId) {
- Map<Product, Integer> mp = getProductsByUserId(userId);
- return mp.keySet()
- .stream()
- .map(product -> product.getPrice() * mp.get(product))
- .reduce(0.0, Double::sum);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement