0

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

lowLatency
  • 5,534
  • 12
  • 44
  • 70

2 Answers2

3

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.

Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130
  • This explains nothing. – user207421 Oct 06 '13 at 19:05
  • 1
    @EJP I am sure you understand how javadoc works and you have to redeclare a method in a sub class or interface if you want to give it a different javadoc even if without the javadoc it would be redundant. – Peter Lawrey Oct 06 '13 at 21:25
  • @PeterLawrey can you please elaborate on : "you understand how javadoc works" as I don't understand what do you mean by this statement – lowLatency Oct 16 '13 at 09:11
  • @Naroji To override a Javadoc of a method in a sub-class, you have to declare the method again. Without considering the Javadoc, this re-declaration would be redundant. – Peter Lawrey Oct 16 '13 at 11:32
1

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.

Alowaniak
  • 571
  • 3
  • 10