Interface implementations and inheritance in the Java collection

Source: Internet
Author: User

Many people are aware of the interface and the abstract implementation of the confusion, attention to distinguish between the implementation of interface and inheritance of the difference, the figure is the interface of dark, light for the implementation of the class, extend for inheritance, implements for the interface implementation

List and set interfaces inherit from collection interface

LinkedList is inherited from Abstractsequentiallist (abstract class, implements the list interface)

ArrayList and Vector are inherited from Abstractlist(abstract class, implements the list interface)

Abstractset is the implementation of the set interface, itself is an abstract class. Inherits from Abstractcollection (abstract class, implements collection interface)

HashSet is inherited from Abstractset and implements the set interface

LinkedHashSet is an inherited HashSetthat implements the set interface

The difference between implementing interfaces and inheritance is that

Class B implements the A interface, that is, Class B implements all the methods defined in the A interface, and the method defined in the A interface is not less than one in Class B, and is to be implemented concretely.
Class X inherits the Y class, and the X class can directly use the method in the Y class (not to implement the method in the Y class, the method has been implemented, of course, the exception of the abstract class OH)

Interface implementations and inheritance in the Java collection

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.