Please enable JavaScript.
Coggle requires JavaScript to display documents.
Java Generics, Examples - Coggle Diagram
Java Generics
Important Terms
-
To declare a bounded type parameter, list the type parameter's name, followed by the extends keyword, followed by its upper bound
-
Type erasure
During the type erasure process, the Java compiler erases all type parameters and replaces each with its first bound if the type parameter is bounded, or Object if the type parameter is unbounded.
TYPE Erasure by Compiler, so no runtime overhead.
Wildcard <?> ( like Object ...root ) and Subtyping . List<?> <-- List< ? extends Number> <-- List< ? extends Integer >
What
-
-
Generics enable types (classes and interfaces) to be parameters when defining classes, interfaces and methods. Much like the more familiar formal parameters used in method declarations, type parameters provide a way for you to re-use the same code with different inputs. The difference is that the inputs to formal parameters are values, while the inputs to type parameters are types.
-
-