How to create lists in Kotlin?


Warning: Trying to access array offset on false in /home3/indiakep/public_html/wp-content/plugins/dw-question-answer/inc/Template.php on line 8
All QuestionsCategory: KotlinHow to create lists in Kotlin?
chetan shidling asked 5 years ago

I need short information.

1 Answers
chetan shidling answered 5 years ago

Here is the code on how to create a list in Kotlin.
 
fun main(args : Array<String>){
var nums = listOf(1,2,3,4)

for(i in nums)
{
println(i)
}
}
 
Output:
 
1
2
3
4