Skip to content

Instantly share code, notes, and snippets.

@rail-rate
Created August 16, 2019 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rail-rate/f9a99b5dc9dcffc9e7f0263b9b2436c9 to your computer and use it in GitHub Desktop.
Save rail-rate/f9a99b5dc9dcffc9e7f0263b9b2436c9 to your computer and use it in GitHub Desktop.
try-catch4
fun main(args: Array<String>) {
val text = "abcde"
try{
val number = text.toInt()
println("number = ${number}")
}catch(e : NumberFormatException){
println("${text}は数字に変換出来ません")
}catch(e : ArrayIndexOutOfBoundsException){
println("文字を入力してください")
}catch(e : Exception){
println("何かのエラーが起きました")
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment