Index access Operator in Kotlin Hindi

 Index access Operator in Kotlin Hindi

Here are some expressions using index access operator with corresponding functions in Kotlin.

ExpressionTranslated to
a[i]a.get(i)
a[i, n]a.get(i, n)
a[i1, i2, ..., in]a.get(i1, i2, ..., in)
a[i] = ba.set(i, b)
a[i, n] = ba.set(i, n, b)
a[i1, i2, ..., in] = ba.set(i1, i2, ..., in, b)

Example: Index access Operator

fun main(args: Array<String>) {

    val a  = intArrayOf(1, 2, 3, 4, - 1)
    println(a[1])   
    a[1]= 12
    println(a[1])
}

When you run the program, the output will be:

2
12