- Generics: parameterization of variable types
- You need to qualify an implementation class for an interface when the subclass of the class is its generic type. For example, T can only be used to implement the type of the List interface <t extend list>
- If you do not specify a generic category, you will automatically use <t extend Object>, so you will receive any Java type when not used by default, note: Arrays are also subclasses of Object
- There is a custom generic class: generictest<t>{}, now declaring a reference generictest<? Extends list> ge=null;
This reference means that you can point to a type of generictest, a generic type is an instance of the list interface system, and you can ge= new generictest< arraylist>; or ge= generictest< Linkedlist>
- There is a custom generic class: generictest<t>{}, now declaring a reference generictest<? Super List> Ge=null;
This reference means that you can point to a type of generictest, a generic type is an instance of the list interface system, ge= generictest< collection> but ge= generictest< Linkedlist> will make an error.
- Generic use, often see Generictest<? > GE, actually this is generictest< Extends object> GE's abbreviation, meaning that the generic type can be any one of the Java types
Santhiya Park Java SE Training Summary (52-) (generics)