12. 1. 5. Introducing Generic Types |
|
- A generic type can accept parameters.
- A generic type is often called a parameterized type.
- You pass reference types in angle brackets to generic types.
|
|
E is called a type variable, namely a variable that will be replaced by a type. |
- A generic type that uses a type variable E allows you to pass E when declaring or instantiating the generic type.
- If E is a class, you may also pass a subclass of E
- If E is an interface, you may also pass a class that implements E.
- By convention, you use a single uppercase letter for type variable names.
|