Java Learner logo
← Exit to Module 12: Generics and Type Safety lessons
Module progress · 0%Lesson · 18 min

Module 12: Generics and Type Safety

Lesson focus

Bounded Type Parameters

Use upper and lower bounds to restrict acceptable types.

Upper bounds (<T extends Number>) limit types to Number or subclasses—enables numeric operations.

Lower bounds (? super T) support contravariance for consumers (e.g., Comparator<? super T>).

Remember PECS: Producer extends, Consumer super.

Lesson quiz

What does `<? super T>` represent?

Next lesson →