kotlin variables code example

Example 1: kotlin variable

val name = ”Marcin” // Can't be changed
var age = 5 // Can be changed
age++

Example 2: how to define variable in kotlin

val firstName: String = "Chike"
val variable name: Typeofthevariable = TheValueofyourvariable

Example 3: return type in kotlin function

//Function having two Int parameters with Int return type
fun sum(a: Int, b: Int): Int {
    return a + b
}

Example 4: kotlin var and val

val declares a read-only property, var a mutable one