Generics is a facility for generic programming, allowing classes, interfaces and methods to operate on various types of objects. It basically allows a type to be a parameter to methods, classes and interfaces.

Generics removes the need to typecast by restricting the accepted types and hence guaranteeing run time type safety.

Type Parameters
Type parameters are used to implement generics. The type parameters are placeholders for the actual type to be used with the classes, interfaces or methods.

#variance #generics #generics-in-kotlin #generics-programming #invariance

Generics in Kotlin
1.15 GEEK