...

Mobile App Development - Kotlin

Back to Course

Lesson Description


Lession - #394 Kotlin Array


Arrays are utilized to store different qualities in a solitary variable, rather than making separate variables for each value.

To create a array, utilize the arrayOf(>
function, and place the values in a comma-separated list inside it

Accessing element from array

You can access to an array element by referring to the index number, inside square brackets.


Let's see an example





fun main(>
{ val numb = arrayOf("one", "two", "three", "four">
println(numb[0]>
//element access println(numb.size>
//array length }



Output



Try it here

Kotlin queue?
Queue is an interface. So you can't instantiate an interface, you have to implement it or instantiate a class that implement it. For example, you can do var queue: Queue = ArrayDeque(>
. ArrayDeque implements Queue .