1

Why is it that some abstract methods in interface hierarchies are redeclared as abstract further down?

iterator() for example, abstract in Collection is redeclared in Set and List, and again further down the Set hierarchy in NavigableSet.

I'd like to understand why this is done from a design point of view, or if there's some historical reason, etc. (I haven't seen anything about it in texts I've read sofar, and could not find anything in the JLS).

It is similar with other methods in Collection: add, size, remove, removeAll, clear, contains, containsAll, equals, isEmpty

2
  • 1
    See this Commented Mar 3, 2020 at 23:37
  • @Filip Thanks for the link though the answer there isn't really clear to me. This answer is clearer - that if a super interface is added later, it's accepted practice to not delete the methods. The examples I mentioned though - Collection, List, Set - are from the same version, 1.2. NavigableSet is from 1.6. Commented Mar 4, 2020 at 17:44

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.