Question: I am getting these errors for getcountgroupbymedia Cannot infer type argument(s) for flatMap(Function super T,? extends Stream extends R>>) gettotalfeesgroupbymedia has errors too and gettotalitemsgroupbymedia
I am getting these errors for getcountgroupbymedia Cannot infer type argument(s) for
gettotalfeesgroupbymedia has errors too and gettotalitemsgroupbymedia kindly could you solve it and replace it with the correct code
package adminSite;
import java.util.Comparator; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Random; import java.util.function.Function; import java.util.function.Supplier; import java.util.stream.Collectors;
import yourPrime.*;
public class FuncUtil { private Map
Comparator
userDb.values().stream() .sorted(comparator) .map(details) .forEach(System.out::println); }
// TODO create a method to return the average outstanding fees from all accounts using Java 8 stream and lambda expression. // public double getAverageOutstanding() { return userDb.values().stream() .mapToDouble(Subscriber::getFees) .average() .orElse(0); } // TODO create a method to return the outstanding fees from all accounts group by the media type. // You should make use of Java 8 Streams and lambda expression to do this - return map // public Map
// Loop through each media type for (MyMedia.Media media : MyMedia.Media.values()) {
// Compute the total fees for the current media type Double fees = userDb.values().stream() .flatMap(subscriber -> subscriber.getMedia().get(media).stream()) .mapToDouble(MyMedia::getFees) .sum();
// Store the total fees for the current media type in the Map totalFees.put(media.toString(), fees); }
// Return the Map of total fees for each media type return totalFees; } public Map
// Loop through each media type for (MyMedia.Media media : MyMedia.Media.values()) {
// Count the number of items for the current media type Long count = userDb.values().stream() .flatMap(subscriber -> subscriber.getMedia().get(media).stream()).count();
// Store the item count for the current media type in the Map itemCounts.put(media.toString(), count); }
// Return the Map of item counts for each media type return itemCounts; }
public Map
// TODO create a method to return the total number of items from all accounts using Java 8 streams and lambda expression. // group by the media type. Use the programming logic (idioms) that you've implemented in the getTotalFeesGroupByMedia() // method as a source of inspiration in completing this method. // }


@override
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
