Java 1.5 model ~~

xiaoxiao2021-03-05  23

Generics is launched in SUN, in SDK1.5, its main purpose is to establish a set of safety collection frameworks such as linked lists, haveh mappings, etc. are SUN model documents http: // java . Sun.com / J2SE / 1.5 / PDF / generics-tutorial.pdf.

1. The generic class declaration can use the "Class Name " to declare a class. In order to distinguish between the ordinary class, this declaration is called a generic class, such as: Class a where A is a generic The name of the class, E is a generic, that is, we don't specify what type of data, which can be any object or interface, but cannot be basic type data. You can also use E to represent generics, you can use any reasonable identifier, but it is best to distinguish between the type name we are familiar with. When the generic class declaration, the generic preferences given by the "General list" can be used as the type of member variable of the class, the type of method, and the type of local variable. The genre and common type of generic class is completely similar, constructed by member variables and methods, such as Class Chorus {Void Makechorus (E Person, f Yueqi) {yueqi.tostring (); Person .tostring ();

转载请注明原文地址:https://www.9cbs.com/read-37626.html

New Post(0)