Multi-catch
2024-10-16 20:53:52
It’s relatively common for a try
block to be followed by several catch
blocks to handle various types of exceptions. If the bodies of several catch
blocks are identical, you can use the multi-catch
feature (introduced in Java SE 7) to catch those exception types in a single catch
handler and perform the same task. The syntax for a multi-catch is:
catch (Type1 | Type2 | Type3 e)
Each exception type is separated from the next with a vertical bar (|
). The preceding line of code indicates that any of the types (or their subclasses) can be caught in the exception handler. Any number of Throwable
types can be specified in a multi-catch
.
最新文章
- Vue.js学习笔记(4)
- 集合和String
- AC日记——codevs 1688 求逆序对
- 161128、Redis 4.0发布及其新功能介绍
- conpot_usage简要说明
- wdcp-apache配置错误导致进程淤积进而内存吃紧
- Java并发编程:Lock
- dyld: Symbol not found: _OBJC_CLASS_$_UIBlurEffect
- 深入理解PHP对象注入
- oh-my-zsh配置
- (5)UIView常见属性
- CoolBlog开发笔记第5课:请求与响应
- java无需解压zip压缩包直接读取包内的文件名(含中文)
- ubuntu中利用qtcreator引用opencv249及采起采集卡的共享库
- redhat7.3 superset的离线安装
- 学习笔记TF025:自编码器
- gitlab 搭建自己的源代码管理器
- java从命令行接受多个数字求和输出
- MySQL笔记(八)存储过程练习&;补充
- Win7建立FTP站点