"Iterable<Element> cannot be cast to List<Element>" - Isn't `List` a type of `Iterable`?

Viewed 43803

I called a getElements method which returns Iterable<Element>.

I did this:

List<Element> elements = (List<Element>) getElements();

This generates the error:

java.lang.ClassCastException: com.utesy.Element$3 
cannot be cast to java.util.List

I thought a List was a type of Iterable?

10 Answers
Related