I am taking in a String of a movie's release year, and an ArrayList of films (String title, int release year, enum genre etc...). The parameter String year is the users input of search which will be compared to each film to find a film that has the matching release year. The matches will be saved into an ArrayList. By keeping the parameters as (String year, ArrayList films), how can I compare each film's year with the user's input of a year to search for? I have tried casting these but was unsuccessful.
public ArrayList<Film> compareYear(String year, ArrayList<Film> films)
{
ArrayList<Film> yearMatches = new ArrayList<Film>();
for(Film f : films) //search through ArrayList of films
{
int years = f.getYear(); //gets the year for each film and compares it to user input search "year"
if(years == year) {
yearMatches.add(f);
}
}
return yearMatches;
}