import java.io.IOException /** * 异常捕获与处理 */ object excepitonUse { def main(args: Array[String]): Unit = { try { throw new IOException("throw a user define exception!!!") } catch { case e1: IOException => printf("found io exception...") case e2: IllegalArgumentException => { printf("do something when illegal happened.") } } finally { printf("finally ......") } } }
原文地址:https://www.cnblogs.com/yxj0728/p/9281777.html
时间: 2024-10-12 19:04:22