java - Why do so many methods use Collection rather than Iterable? -
with c# grew love ienumerable<t>
interface. there lot of cases that's want give out , take in. in addition it's useful in .net library. have example constructor on list<t>
class takes ienumerable<t>
.
i have work java @ moment, , naturally wanted use equivalent iterable<t>
interface. however, doesn't seem can use anywhere. seems using extended collection<t>
interface instead. why this?
as example, have arraylist<t>
constructor takes collection<t>
:
constructs list containing elements of specified collection, in order returned collection's iterator.
why not take iterable<t>
instead?
iterable added in java 5. means older methods (most of them) use collections. newer methods take iterable haven't used it. :(
i think problem iterable collections.
Comments
Post a Comment