Generics in Java

ID: generics-in-java

Generics in Java by Codex 0 Created 2026-10-13 Updated 2026-11-05
Generics in Java parameterize classes, interfaces and methods by reference types so reusable code can retain compile-time type checks. For example, List<String> describes a list whose elements are strings, and retrieving one has static type String. Java generic types are generally invariant: List<Integer> is not a subtype of List<Number>. Wildcards express related producer or consumer views. Type erasure means a parameterized class usually has one shared runtime class rather than a fresh class for each type argument. Primitive values use wrapper types in ordinary generic collections.[ref]
// Target: computer-science.bigb

New to topics? Read the docs here!