How do I fix “The expression of type List needs unchecked conversion…’?

This is a common problem when dealing with pre-Java 5 APIs. To automate the solution from erickson, you can create the following generic method: public static <T> List<T> castList(Class<? extends T> clazz, Collection<?> c) { List<T> r = new ArrayList<T>(c.size()); for(Object o: c) r.add(clazz.cast(o)); return r; } This allows you to do: List<SyndEntry> entries = … Read more