首页 > 建站教程 > dart >  Dart编程实例 - 异常处理Finally 块正文

Dart编程实例 - 异常处理Finally 块

Dart编程实例 - 异常处理Finally 块

main() {

   int x = 12;

   int y = 0;

   int res;  

   try {

      res = x ~/ y;

   }

   on IntegerDivisionByZeroException {

      print('Cannot divide by zero');

   }

   finally {

      print('Finally block executed');

   }

}