The previous section used spring's applicationcontext interface to view the methods provided by spring and open the jar package. The following information is displayed: Java Code
- Public abstract interface Org. springframework. context. applicationcontext extends ... {
- Public abstract Org. springframework. context. applicationcontext getparent ();
- ...
-
- }
It is found that there is an abstract before the interface. Why does there be an abstract interface? Isn't all interfaces Abstract? Is there any special significance for writing them.
some netizens posted some comments on interfaces written in some famous Java books online:
in Java in a nutshell,
"all methods of an interface are implicitly abstract, even if the abstract modifier is omitted. "
in thinking in Java,
" the abstract keyword, which allows you to create one or more methods in a class that have no definitions-You provide part of the interface without providing a corresponding implementation, which is crea Ted by inheritors. The interface keyword produces a completely abstract class, one that provides no implementation at all. "
the conclusion is that abstract interface is interface, and there is no difference between the two.
but why do they want to do that? Is the implicit abstract automatically added in the jar package? I found the Source Code . Sure enough, the source code does not abstract: java code
- Public interface applicationcontext extends listablebeanfactory, hierarchicalbeanfactory,
- Messagesource, applicationeventpublisher, resourcepatternresolver {
-
- Applicationcontext getparent ();
-
- ...
- }
Therefore, the conclusion is:
The interface has been implicitly abstract, and the interface and abstract interface have the same role, but abstract interface is a more complete representation.