Great job learning about generics! In this lesson we’ve covered how:
- Generics help us make generic, scalable code.
- The diamond operator (
<>) is used to define generic classes, interfaces, or methods.
- Generics provide compile-time type safety and bug detection as opposed to raw types.
- We can create multiple bound generic classes, interfaces, and methods.
- Wildcards are used to define unknown types.
- To Add upper bounds to type parameters and wildcards.
- To Add lower bounds to wildcards.
Knowing these topics will help you create scalable, type safe code, and give you a better understanding of the Java collections framework (we’ll learn about this later).
Use the workspace to continue exploring generics. Some ideas to try out:
extendson wildcard types. Specifically what type of references can you read and write when using
- Multiple upper bounds when using type parameters.