January 2018
Intermediate to advanced
434 pages
14h 1m
English
Let's understand how to convert one data type into another by following the steps below:
fun main(args: Array<String>) { var a = 1 var b: Float = a.toFloat() var c = a.toLong() println("$a is Int while $b is Float and $c is Long")}
fun main(args: Array<String>) { var a = 1000000000000000000L var b: Float = a.toFloat() var c = a.toInt() println("$a is Long while $b is Float and $c is Integer")}
The output of this code is as shown:
1000000000000000000 is Long while 9.9999998E17 is Float and -1486618624 is Integer
fun ...
Read now
Unlock full access