Firstly, I'm not very good at this java lark, so bear with me...
I have a map where the keys are Strings representing the title of a film and the values are Sets of actors, represented by objects of class Actor which each have their own attributes.
What I want to do is iterate over the map, returning the film title and the actors in a meaningful way.
I've got the map iteration part but I can't figure out how to do the next loop which produces the values from the Set of Actors.
Here's what I have:
Map <String, Set> filmCollection = new HashMap<>();
Actor a1 = new Actor("Joe Smith", "20071977");
Actor a2 = new Actor("Kate Jones", "01011980");
Actor a3 = new Actor("Frank DeFrank", "02021945");
Set <Actor> s1 = new HashSet<>();
Set <Actor> s2 = new HashSet<>();
s1.add(a1);
s1.add(a2);
s2.add(a3);
s2.add(a1);
filmCollection.put("The Best Film", s1);
filmCollection.put("The Nearly Best Film", s2);
Set<String> collectionKeys = filmCollection.keySet();
for (String eachFilm : collectionKeys)
{
System.out.println(eachFilm + " stars the actors ");
}
I know this is basic stuff and is probably very simple, but i'm learning and I've been searching and trying things all day - my head feels like it might explode soon! Any guidance would be appreciated.