Interface & abstract interface)

Source: Internet
Author: User
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
  1. Public abstract interface Org. springframework. context. applicationcontext extends ... {
  2. Public abstract Org. springframework. context. applicationcontext getparent ();
  3. ...
  4. }

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

  1. Public interface applicationcontext extends listablebeanfactory, hierarchicalbeanfactory,
  2. Messagesource, applicationeventpublisher, resourcepatternresolver {
  3. Applicationcontext getparent ();
  4. ...
  5. }

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.
 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.