异常捕获与处理二

package first

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*

var getInt:()->Int={
 1/0
}
fun getInt2():Int
{
 if((1/1)!=0) {
  throw object : Exception(){}//用object: 代替Java的new
 }
         return 1/1
}
 fun main() {

getInt2()
 }

 

posted @ 2021-09-11 13:57  cgy33  阅读(28)  评论(0)    收藏  举报