Java Programming Week-end (10)

Source: Internet
Author: User

In the 10th week we contacted a knowledge point that we are not very unfamiliar with, generic classes. In the previous learning process, there was a generic array in the Employee class. Of course this week's study is in-depth study of what is generic, how to define, how to use. First of all, let's talk about generics , generics, or "parameterized types". When referring to a parameter, it is most familiar to define the method when the physical parameter is called and then pass the argument when calling this method. So how do parameterized types understand? As the name implies, the type is parameterized by the original specific type, similar to the variable parameter in the method, when the type is also defined as a Parameter form (which can be called a type parameter), and then the specific type (type argument) is passed in when using/calling. Generic classes, generic interfaces, generic methods, and so on, can be used when using generics. There is also a type of wildcard character. What are the wildcard characters in Java? , it is mainly used on the formal parameters of the method, in order to compensate for the problem of the parameter transfer caused by the generic mechanism, there are three kinds of wildcard characters to classify the unbounded wildcard:?, sub-class qualification:? Extends Object (the upper bound of the wildcard), the parent class qualifies:? Super Integer (the lower bound of the wildcard character). type wildcard character upper bound by shape such as pair<? extends number> form definition, corresponding to the type wildcard lower bound is pair<? super number> form, which means the opposite of the upper limit of type wildcard characters. Although the content of this week and other times to be familiar with, but also need to look at the code more practice, to be familiar with the master.

Java Programming Week-end (10)

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.