Skip to main content

6 docs tagged with "generics"

View all tags

Generics

How Java generics provide compile-time type safety through parameterised types — covering generic classes, generic methods, bounded type parameters, and the key constraint that generics only work with reference types.

Type Erasure

How the Java compiler removes all generic type information before producing bytecode, why this design choice was made for backward compatibility, and what limitations it imposes at runtime.

Type Inference

How the Java compiler deduces types automatically — covering the diamond operator, generic method type inference, `var` (Java 10+), and lambda target typing — and where inference has limits.

Wildcards

How Java's wildcard type arguments — `?`, `? extends T`, and `? super T` — express variance in generic APIs, and how the PECS rule guides correct usage.

Wrapper Classes

Java's eight primitive wrapper types — Integer, Long, Double, and friends — covering autoboxing, caching traps, parsing, and when to use primitives vs objects.