August 2018
Beginner
178 pages
4h 56m
English
To cast from one type to another, Kotlin uses the as keyword. Here’s how you would cast Any type to an Int type:
fun casting(any: Any) { val num = any as Int}
During runtime, before casting, the JVM will check if the source type can be cast to target type. If not, ClassCastException will be thrown.
Read now
Unlock full access