异常
异常类
基类:
Exception
抛出异常:
throw MyException(
"Hi There!")
捕获异常
try {
}
catch (e: SomeException) {
}
finally {
}
finally不是必须的
try是一个表达式
try可以有返回值
val a: Int? =
try {
parseInt(input) }
catch (e: NumberFormatException) {
null }
异常检查
Kotlin中没有异常检查。
转载请注明原文地址: https://www.6miu.com/read-65281.html