Type casting problem with java for-each loop
- by pharma_joe
Hi,
I have traced an issue with an application I am developing, it is giving me a type cast exception. Funny thing is it is saying it cannot cast "entities.Movie cannot be cast to entities.Movie"?! movies is an ArrayList.
try {
movies = getMovies();
} catch (Exception e) {
e.printStackTrace(System.out);
} finally {
try {
for (Movie movie : movies) {
output.append(" <tr>\n");
output.append(" <td>" + movie.getId() + "</td>");
output.append(" </tr>\n");
}
} catch (Exception e) {
e.printStackTrace(System.out);
}
}