Why Iterator<E> iterator() is put in Collection, AbstractCollection when already in Iterable [duplicate]

StackOverflow https://stackoverflow.com/questions/19211859

  •  30-06-2022
  •  | 
  •  

문제

When Iterator iterator() is put in Iterable interface and this is extended by Collection interface and AbstractCollection interface, why this is again mentioned in Collection/AbstractCollection as no definition is given for this in abstract class.

Please help me to understand what I am missing in this from design perspective

도움이 되었습니까?

해결책

The iterator() appears in Iterator and Collection as the Javadoc is different. In AbstractCollection it is different again, but doesn't appear to add much value.

다른 팁

Well Iterable is since 1.5 whereas Iterator and Collection are since 1.2. Not sure why AbstractCollection defines it again though, it's javadoc is slightly different though.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top