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
Define methods for generating a set, adding a list of actors into one, and for combining two sets.
Data from worked example 19.2.
Step by Step Answer: