The get function

Another way to access elements is by using the get(index) function. Pass the index number of the list item to the get function and it will return the item from the list. intArr.get(0) and intArr[0] are the same. See the following example, where the while loop increments the index value and the get(index) function returns the item:

index = 0
while(index < arraySize){
println("At index $index Value ${intArr.get(index)}")
index++
}

Both examples will give the same output.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.16.137.117