-
Book Overview & Buying
-
Table Of Contents
-
Feedback & Rating

Programming Kotlin
By :

Kotlin is designed primarily as a language for the Java Virtual Machine (JVM), and when the JVM was first designed, generics were not included as a feature. Over time it became apparent that this was a major flaw of the language, and so in Java 1.5 (or Java SDK 5), released in 2004, generics were added as a feature to the compiler.
However, because of a desire to stay backwards compatible with previous versions of Java, the designers of Java decided that generics would be implemented using a technique called erasure. Erasure is the name given to the process by which the compiler removes type parameters during compilation.
In Java, a class defined as List<T>
in the source code would be compiled simply as List
, or List<Object>
, if you like. This poses problems, some of which have already been introduced:
fun print(list: List<String>)
and fun print(list: List<Int)
will have the same function...