Java-preliminary Understanding-Common Object API (collection framework-generic-generic interface)

Source: Internet
Author: User

One.

What is a generic interface? The previous example created so many classes that it was cumbersome.

The first thing to understand is that the interface is an abstract class, and after the declaration, the following class is implemented. The methods in the interface are the classes that are implemented. This combines the interfaces with generics. In the preceding chapters, you combine generics with classes, methods.

A generic definition on a class is a generic class that is defined on an interface and is a generic interface. (interface defined, must be implemented)

Here is a program to express the meaning of all written out, define interfaces, classes to implement, the main function to create objects. At the time of definition, the parameter type is indeterminate and is represented by generic T, but it must be specified when implemented.

Then there is further development, that is, when the class is implemented, it still cannot determine the type of the parameter until the object is created in the main function.

There is no problem with running this way.

The use of generic interfaces is divided into two types.

Java-preliminary Understanding-Common Object API (collection framework-generic-generic interface)

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.