/** * getTopMovies method, get all top rated movies from list * @param <T> The type of the list * @param movieList List with all the rated movies * @return Returns a list with only the top movies */ public <T> MovieList<T> getTopMovies (MovieList<? extends Movie> movieList) { MovieList<Movie> topMovieList = new MovieList<Movie>(); for (Movie movie : movieList) { if (movie.rate > 4) topMovieList.add(movie); // OK!, since all types are known. } return (MovieList<T>) topMovieList; //Cast to right Type }