Im starting to learn Kotlin and wanted to try a little code, just to read and print an int array from the user, this is my code
import java.util.*
fun main(){
val scan = Scanner(System.`in`)
println("Enter the number of elements: ")
var arrayInt = IntArray(scan.nextInt())
println("Size of the array: ${arrayInt.size}")
println("Enter the numbers: ")
for(item in arrayInt)
arrayInt[item] = scan.nextInt()
for(i in arrayInt)
print("${arrayInt[i]} ")
}
but when I run the code the only thing i get print is the last number I enter and some 0s, what im doing wrong? thanks