Generics
Generics allow functions, classes, and interfaces to be written in terms of placeholder types that are specified when the code is actually used, enabling reusable, type-safe code without duplicating logic for each concrete type.
22 resources across 4 libraries
Glossary Terms(3)
Generics
Generics allow functions, classes, and interfaces to be written in terms of placeholder types that are specified when the code is actually used, enabling reusa…
Static Typing
Static typing is a language design approach in which the type of every variable is known and checked at compile time, before the program runs.
Type Inference
Type inference is a compiler feature that automatically determines the type of an expression or variable from context, without requiring the developer to write…
Study Notes(8)
Generics in Free Pascal
Understand how Free Pascal's generic types and routines let you write reusable, type-safe containers and algorithms with `generic` and `specialize`.
Collections and Generics in VB.NET
Move beyond fixed arrays to type-safe, resizable generic collections like List(Of T) and Dictionary(Of TKey, TValue), and write your own generic methods.
Generics in Dart
Learn how Dart's generic types let you write reusable, type-safe classes and functions that work across many types without sacrificing compile-time checking.
Generics in Java
Understand how Java generics provide compile-time type safety with type parameters, bounded types, wildcards, and the concept of type erasure.
Generics in TypeScript
Learn how TypeScript generics let you write reusable, type-safe code that works across many types without losing type information.
Generics in Rust
Generics let you write functions, structs, and enums that work over many types while remaining zero-cost at runtime.
Generics in Swift
Understand how Swift generics let you write flexible, reusable, type-safe code that works with any type.
Generics Explained
Understand how C# generics let you write type-safe, reusable code that works across many types without sacrificing performance or requiring casts.
Cheat Sheets(1)
Interview Questions(10)
Covariance and Contravariance Explained
Covariance and contravariance describe how subtyping relationships between types carry over to derived types like arrays, generics, and function signatures — c…
What Are Generics in Java?
Generics let a class, interface, or method be parameterized over types, so the same code works with different data types while the compiler enforces type safet…
What Are Templates in C++?
C++ templates let you write a function or class once with a placeholder type parameter, and the compiler generates a fully concrete, type-checked version for e…
Generics vs Templates: Java vs C++
Java generics and C++ templates both let you write type-parameterized code, but they resolve that parameterization completely differently: Java erases generic…
What is a Template Class?
A template class is a class defined with one or more type parameters so the compiler can generate a distinct, type-specific version of it for each concrete typ…
What is a Generic Class?
A generic class is a class declared with one or more type parameters in angle brackets — like `class Box<T>` — allowing the same class definition to operate on…
Bounded Type Parameters Explained
A bounded type parameter restricts a generic type parameter to a specific type or its subtypes, written as `<T extends Upper>` in Java, so the generic class or…
What is Type Erasure?
Type erasure is the mechanism by which the Java compiler enforces generic type safety at compile time and then removes (erases) all generic type parameter info…
What is a Wildcard Generic in Java?
A wildcard generic, written as "?", represents an unknown type argument in generics and lets a method accept a family of parameterized types instead of just on…
What Are Generics in TypeScript and Why Use Them?
Generics let you write functions, interfaces, and classes that work with a type parameter decided at the call site, so you get full type safety without duplica…