Kotlin – Constant and Variable declarations

This is how you declare constants in Kotlin.

val a: Int = 10
val b: Long  = 120 
val c: Float = 1.2f
val d: Int
d = 10

Note that the data types start with an initial capital letter.
Other data types include Float and Double.

For variables, the declaration would be as shown below.
var a: Int = 10

Note that the mentioning the type explicitly is redundant. The example below shows that the type is inferred as an Int.
var d = 10

Leave a comment