Write a program to determine how many actors there are in the data set in Worked Example

Question:

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.

Data from worked example 19.2.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

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

Step by Step Answer:

Related Book For  book-img-for-question
Question Posted: