Skip to content
Advertisement

Stream API – how to return map of unique task name – average result?

I have a CourseResult class

JavaScript

Here is my method signature

JavaScript

I need to return an average result of every task.

Advertisement

Answer

I’d flatMap that stream to a stream of the taskResults‘ entries, and then use Collectors.averagingDouble to get the average per task:

JavaScript
User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement