博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
自定义异常时如何定义checked异常和unchecked异常
阅读量:7082 次
发布时间:2019-06-28

本文共 898 字,大约阅读时间需要 2 分钟。

When defining your own exception type, study the existing exception classes in the Java API and try to extend a related exception class. For example, if you’re creating a new class to represent when a method attempts a division by zero, you might extend classArithmeticException because division by zero occurs during arithmetic. If the existing classes are not appropriate superclasses for your new exception class, decide whether your new class should be a checked or an unchecked exception class. If clients should berequired to handle the exception, the new exception class should be a checked exception (i.e., extend Exception but notRuntimeException). The client application should be able to reasonably recover from such an exception. If the client code should be able to ignore the exception (i.e., the exception is an unchecked one), the new exception class should extend RuntimeException.

 

转载地址:http://bdlml.baihongyu.com/

你可能感兴趣的文章
Python pyspider 安装与开发
查看>>
hexo+css创建自己的blog(搭建)
查看>>
[译] 使用 Sami 生成 PHP 文档
查看>>
GitChat · Python | 零基础小白如何入门 Python 编程
查看>>
Spring、Spring Boot和TestNG测试指南 - 测试Spring MVC
查看>>
Memory Management and Circular References in Python
查看>>
用node+express+mongoDB实现用户登录注册模板
查看>>
微信小程序server-2-实现会话层
查看>>
vim下处理文档中的\r\n\t字符
查看>>
php常见术语
查看>>
看例子,学 Python(三)
查看>>
git心得
查看>>
头部组件header.vue
查看>>
golang - 收藏集 - 掘金
查看>>
Promise 的几种通用模式
查看>>
Kubelet源码分析(四) diskSpaceManager
查看>>
用Org-Mode和Jekyll写博客
查看>>
AlphaZero进化论:从零开始,制霸所有棋类游戏
查看>>
创新技术重塑未来物联网
查看>>
庖丁解牛!深入剖析React Native下一代架构重构
查看>>