Introduction to Generics

Explore the concept of generics in Kotlin, including generic functions and interfaces, and learn how to use them effectively.

Introduction of generics in Java

In the early days of Java, it was designed in such a way that all lists had the same type List, instead of specific lists with specific parameter types, like List<String> or List<Int>. The List type in Java accepts all kinds of values; when we ask for a value at a certain position, the result type is Object (which, in Java, is the supertype of all the types).

Get hands-on with 1200+ tech skills courses.