How to convert String to Int in Kotlin?

前端 未结 7 1072
再見小時候
再見小時候 2020-12-15 02:30

I am working on a console application in Kotlin where I accept multiple arguments in main() function

fun main(args: Array) {
    /         


        
7条回答
  •  不知归路
    2020-12-15 02:51

    val i = "42".toIntOrNull()
    

    Keep in mind that the result is nullable as the name suggests.

提交回复
热议问题