Module 12: Generics and Type Safety
Why Generics?
See how generics eliminate casts and runtime ClassCastException problems.
Before generics, collections stored Object; consumers had to cast, risking runtime errors.
Generics provide compile-time safety and self-documenting code.
Type inference reduces verbosity when instantiating generic classes (new HashMap<>();).