You are working on a Kotlin application where you're converting a String to an Integer using toInt() method. However, the users sometimes input strings that contain non-digit characters. Fill the blanks in the code to handle these incorrect user inputs, output a relevant message and continue with the application execution without crashing.
Hierarchy of exceptions
Handling string conversion errors in user input
Report a typo
Fill in the gaps with the relevant elements
{
val number = "123a".toInt()
} (e: ) {
println("$e has been caught!")
} ___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.