The main content of this week is generics, and we have learned a little bit about generic arrays. Generic Master
Refers to the class object to be processed by the type parameter when defining classes, interfaces, and methods. A generic class is a type that has
A class of one or more variable types. A generic class can have more than one type variable, such as a class class name < generic type identity
1, generic type ID 2, ..., generic type ID 3>{...}. We need to master the implementation of the generic interface, which has two
Method of implementation:
After the generic interface definition is complete, you define the subclasses of this interface, and there are two ways to define the subclasses of the generic interface .
One is directly in the subclass after the sound of the generic type, the other is directly in the sub-class implementation of the interface explicitly given generic types.
We also learned about wildcard characters. Wildcard characters can be divided into two main categories:
(1) Match any type of wildcard character "?" Indicates that any generic object of this type can be received.
(2) Restricted generics in reference passing, you can also set the range cap for a generic object in a generic operation and
range lower limit. The upper limit of the range is declared with the extends keyword, which indicates that the parameterized type may be the specified type
declaration object: class name <? extends class > object name
Definition class: public class name < generic identity extends class >{}
Type, or the Obeject class.
Declared object: class name <? Super Class > object name
Definition class: public class name < generic identity Super class >{}
201671010138 2016-2017-2 "Java Programming" learning experience