Java: why does Collection.addAll can not accept Iterables?

Albert picture Albert · Sep 30, 2010 · Viewed 9.5k times · Source

I wonder why the Collection.addAll() method only accepts other Collections but not Iterables. Why is that?

Any similar method to do that for Iterables?

Answer

Michael Borgwardt picture Michael Borgwardt · Sep 30, 2010

Presumably because the Collection interface was introduced in Java 1.2 whereas Iterable appeared only in 1.5, and changing the interface would break all existing implementations.