© Ted Hagos 2018
Ted HagosLearn Android Studio 3 with Kotlinhttps://doi.org/10.1007/978-1-4842-3907-0_7

7. Generics

Ted Hagos1 
(1)
Manila, National Capital Region, Philippines
 
What we’ll cover:
  • Using generics

  • Constraints

  • Variance

  • Reified generics

Ah, Generics. That devious topic that emerges even in beginner texts. This subject trips up a lot of beginners because it’s tricky to understand and even trickier to explain. But we need to deal with it because without Generics, it’s difficult to work with Collections.

For the most part, Kotlin generics works the same way as Java generics; but they have some differences. In this chapter, we’ll look at how to work with generics and how similar (or different) Kotlin’s generics is from that of Java’s—also, don’t ...

Get Learn Android Studio 3 with Kotlin: Efficient Android App Development now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.