Write a program to determine the 100 actors with the most movies, and the number of movies

Question:

Write a program to determine the 100 actors with the most movies, and the number of movies in which they appear. For each movie, produce a map whose keys are the actors, all with value 1. Merge those maps as in Exercise ••• P19.10. Then extract the top 100 actors from a stream of actors.

Data from exercise P19.10

Write a program to determine how many actors there are in the data set in Worked Example 19.2. Note that many actors are in multiple movies. The challenge in this assignment is that each movie has a list of actors, not a single actor, and there is no ready-made collector to form the union of these lists. However, there is another collect method that has three parameters:
• A function to generate an instance of the target • A function to add an element to a target • A function to merge two targets into one for example, stream.collect(() -> 0, (t,e) -> t +e, (t, u) -> t + u) computes the sum of elements in a Stream. Note that the last function is only needed for parallel streams.
Define methods for generating a set, adding a list of actors into one, and for combining two sets.

Fantastic news! We've Found the answer you've been seeking!

Step by Step Answer:

Related Book For  answer-question
Question Posted: