Last Updated: June 6, 2026
A generic class is a class that declares one or more type parameters in its header and uses them inside its body like real types. The previous lesson explained why generics exist and what raw types cost; this one shows how to write your own parameterized class so a single definition can hold any kind of element. We'll cover the syntax, multiple type parameters, instantiation with the diamond operator, type parameter scope, and why Box<String> and Box<Integer> are unrelated to each other at the type level.