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 implements Queue .