Minor code refinement

This commit is contained in:
Anirban Chatterjee 2020-07-16 00:38:26 +02:00
parent 793db9f42b
commit 8a76711fb5
1 changed files with 3 additions and 3 deletions

View File

@ -28,7 +28,7 @@ class ExceptionHandling {
fun multipleCatchBlock(): Int? {
return try {
val result = 25 / 0
return result
result
} catch (exception: NumberFormatException) {
println("NumberFormatException in the code")
null
@ -69,10 +69,10 @@ class ExceptionHandling {
}
}
fun throwKeyword() {
fun throwKeyword(): Int {
val message = "Welcome to Kotlin Tutorials"
if (message.length > 10) throw IllegalArgumentException("String is invalid")
else println("String is valid")
else return message.length
}
@Throws(IOException::class)