First, the basic concept
- Generics are also known as parameterized types (parameterized type), that is, when defining classes, interfaces, and methods, the type parameter indicates the type of object that will be processed. (e.g. ArrayList Class)
- Generic Programming (Generic programming) means that writing code can be reused by many different types of objects.
- A generic class (generic Class) is a class that has one or more type variables, that is, a class that is created with a type as a parameter.
Second, some characteristics
- A generic class can have more than one type variable. For example: public class pair<t, u> {...}
- A type variable in a class definition is used to specify the return type of the method and the type of the domain, local variable.
Iii. generic methods
- In addition to generic classes, you can define only one method as a generic method, specifying either a method parameter or a return value of a generic type, to be determined when the method is called.
- A generic method can be declared in a generic class or declared in a normal class.
Four, object-oriented programming curriculum learning progress bar
Moonphases |
Number of lines of code (read/write) |
Post Blog volume/Comment blog number |
Classroom/after-school time (hours) |
The most satisfying programming task |
First week |
20/7 |
1/1 |
6/4 |
Write the Hello World program |
Second week |
38/20 |
1/1 |
6/5 |
Experiment two task three |
Third week |
50/30 |
1/1 |
6/7 |
Experiment Three |
Week Four |
58/46 |
1/1 |
6/5 |
Write the output n digits of the numbers, and sum |
Week Five |
67/53 |
1/1 |
6/6 |
Classes are defined and overloaded |
Week Six |
71/60 |
1/1 |
6/4 |
Interface |
Eighth Week |
80/66 |
1/1 |
6/3 |
LAMDBA-expression |
Nineth Week |
85/60 |
1/1 |
6/2 |
Operation of the ID |
Tenth Week |
121/80 |
1/ |
6/2 |
Experiment Nine |
...... |
|
|
|
|
Cumulative |
590/415 |
9/8 |
54/38 |
|
201671010128 2017-10-30 "Java program Design" of the generic programming