Java generics in-depth explanation

Source: Internet
Author: User

Generics (Generic) can address the security of data types by identifying the type of a property in a class or the return value and parameter type of a method at the time of class declaration by means of an identity.

Defined:

Access Permissions class class name < generics 1, generic 2...>{

Property

Method

}

Object is created:

Class name < concrete type > object Name =new class name < concrete type > ();


Defines a point class to represent coordinates, requiring that the data type of the coordinates be integers, decimals, and strings, since there are three kinds of coordinate value data types, then only the object type is received. However, when the coordinates are taken out, there is a risk of a downward transition, and it is not easy to find it during compilation and only throws an exception during run time.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/6C/DF/wKioL1VUyQ_RkUD7AACmdAw47X0190.jpg "title=" 20131120133812750.jpg "alt=" Wkiol1vuyq_rkud7aacmdaw47x0190.jpg "/>









This article from "It Technology Learning and communication" blog, declined reprint!

Java generics in-depth explanation

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.