string to int kotlin code example
Example 1: kotlin string to int
val myStringNumber: String = "100";
val number: Int = myStringNumber.toInt()
Example 2: kotlin string to int
val mystring: String = "999"
try {
val parsedValue = mystring.toInt()
println("The parsed integer value is $parsedInt")
} catch (nfe: NumberFormatException) {
// not a valid int
}
Example 3: parse an int in kotlin
val int = text.toInt()