Learn
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).
Instructions
Use the workspace to continue exploring generics. Some ideas to try out:
- Exploring
super
andextends
on wildcard types. Specifically what type of references can you read and write when usingextends
andsuper
. - Multiple upper bounds when using type parameters.
Take this course for free
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.