201671010114 2016-2017-2 "Java Programming" Tenth Week study summary

Source: Internet
Author: User

This week we learned about generic programming, which reduces the amount of code through generic classes. When calling a generic class, you can do a series of actions by changing the type variable. A generic class can have more than one type variable, and a type variable specifies the return type of the method and the type of the local variable. A generic method can be defined in a normal class or in a generic class, and if the class that implements the generic interface is a normal class, then the type in the angle brackets after the interface must be instantiated. When you invoke a generic method, you put the specific type in the angle brackets before the method name. The type of the return value and the entry parameter is placed in the angle brackets before the method name in the generic method. The type variable has upper and lower bounds, and the upper bounds of the type variable are determined by t+extends+ Class 1. Class 1 is the parent class of a type variable. Pass? +super+ Class 1, determining the Nether, Class 1 is a subclass of a type variable. Pair (? ) indicates that the type of the parameter can be any type. In this programming task, change the calculator class to a generic class. But the subtraction inside the calculator class will go wrong.

201671010114 2016-2017-2 "Java Programming" Tenth Week study summary

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.