How to convert String to Long in Kotlin?

前端 未结 11 1031
旧时难觅i
旧时难觅i 2021-01-31 13:00

So, due to lack of methods like Long.valueOf(String s) I am stuck.

How to convert String to Long in Kotlin?

11条回答
  •  旧时难觅i
    2021-01-31 13:43

    Extension methods are available for Strings to parse them into other primitive types. Examples below:

    • "true".toBoolean()
    • "10.0".toFloat()
    • "10.0".toDouble()
    • "10".toByte()
    • "10".toShort()
    • "10".toInt()
    • "10".toLong()

提交回复
热议问题