Java Documentation: What is meaning of 'methods inherited from interface X

后端 未结 2 1155
南笙
南笙 2021-01-24 12:48

I must be missing some basic Java terminology here:

Classes can be extended, therefore their methods can be inherited by their sub-classes.

Inte

2条回答
  •  温柔的废话
    2021-01-24 13:32

    I guess you are referring to the statements like this from the generated JavaDoc HTML:

    Methods inherited from interface java.util.Set ...

    Inheritance in this sense means that the signature of the methods in question is inherited, but not necessarily the implementation. The reason for that is simple: In Java you usually do not look into the implementations of third party code, but only into the interfaces with their signatures and JavaDoc.

    So, basically, the signatures of those methods are inherited from interface Set and implemented in the HashSet or AbstractSet. Hence, actually it is implementing the interface Set.


    Sidenote: In Java 8, you can have Interfaces implementing methods, but that's a different story.

提交回复
热议问题