How to convert string into integer 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 convert string into integer in Kotlin?
chetan shidling asked 5 years ago

I need short information.

1 Answers
chetan shidling answered 5 years ago

Here is the code to convert string into Integer in Kotlin.
 
fun main(args : Array<String>){
var str : String = “4”
var num1 : Int = str.toInt()
num1++
println(“The Integer after increment is $num1”)
}
 
Output:
 
The Integer after increment is 5