Java
Generics in Java
Generics let a class or method work with a type supplied by the caller, moving whole families of errors from runtime to compile time.
Generic classes and methods, bounded types, wildcards and type erasure.
3 notes
Generics let a class or method work with a type supplied by the caller, moving whole families of errors from runtime to compile time.
Bounds restrict what a type parameter may be, and wildcards let a method accept a family of parameterised types safely.
Generic type information exists only at compile time. Knowing what the compiler removes explains every generics restriction.