Question: I'm doing a project for college and have hit a wall with how to search through my hashmap and add the results to a List.

So far i have a Recommendation class with these variables as well as getters,setters constructor and hashcode and equals : 

```
private String title, queryName,Director,summary,myComments,category;
private double Rating;
private int myRating;
private ArrayList<String> cast = new ArrayList<>();

```

So what i want to do is search through this map of Recommendations for an actors name and add the results to a List. This is what i've done so far : 
 private Map recs = new HashMap<>();

```
public void byActor(String actor)
{

    if(recs.containsKey(actor))
    {

        System.out.println(" The Actor "+actor + " has been in these films ");

    }

```

If the actor isn't in the hashmap i have to get recommendations off a website API,which should return it as a list or recommendations and add it to the hashmap ( which will be a local store ) 

How do I add the results of the search to a list and add a list to a hashmap?

Answer: 
It seems you are supposed to create a local store containing a map of actor names and a list of Recommendations (I probably would named Recommendation Movie). 

**Method to create local store**

```
public Map<String, List<Recommendation>> localStoreOfMovies() {

  // Call an API based on actor names, or maybe you have local list
  Map<String, List<Recommendation>> localStore = 
         new HashMap<String, List<Recommendation>>();

  List<Recommendation> movies = new List<Recommendation>();
  // Add robert de niro movies to movies list 
  localStore.put("robertdeniro",  movies);

  return localStore;
 }

```

**Get list of Recommendation based on actor**

If you are able to create the local store and create a map of actors, and list of recommendations, getting the list based on actor becomes simple, you can just do

```
public List<Recommendation> byActor(String actor) {
    // all movies are coming from instance local store
    return localStore.get(actor);
}

```
To add a data on a list

```
myList.add(myData);

```

to add a data from a list to a map :

```
myMap.put(myKey, myValue);

```

if you want to add every data from the list : 

```
for(dataType data : myList){ // this is a foreach
  myMap.put(myKey, myValue);
}

```

Cheers