如何将整数数组作为变量并打印出Kotlin中数组的第一个元素?
我是科特林的新手
,我理解该代码应该有效,但不是
fun main(args: Array<Int>) {
//printing out the first element of the array
println(args[0])
}
main([12,3,4,5])
I am new to kotlin
From what I understanding this code should be working but it isn't
fun main(args: Array<Int>) {
//printing out the first element of the array
println(args[0])
}
main([12,3,4,5])
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
main
函数是程序输入点,需要具有特定的函数签名。另外,要从硬编码元素中创建一个数组,您将使用
arrayof()
。您可以找到有关它的更多信息。一个工作的例子是:
The
main
function is the program entry point and needs to have a specific function signature.Also, to create an array in Kotlin from hard-coded elements you would use
arrayOf()
. You can find more about it here.A working example would be: