1) Checked: are the exceptions that are checked at compile time. If some code within a method throws a checked exception, then the method must either handle the exception or it must specify the exception using throws keyword
2) Unchecked are the exceptions that are not checked at compiled time. In C++, all exceptions are unchecked, so it is not forced by the compiler to either handle or specify the exception. It is up to the programmers to be civilized, and specify or catch the exceptions.
In Java exceptions under Error and RuntimeException classes are unchecked exceptions, everything else under throwable is checked.
Should we make our exceptions checked or unchecked?
If a client can reasonably be expected to recover from an exception, make it a checked exception.
If a client cannot do anything to recover from the exception, make it an unchecked exception
异常处理:检查异常与非检查异常的权衡
本文探讨了在编程中选择检查异常和非检查异常的策略,提出了根据异常是否允许客户端恢复来决定其类型的指导原则。
643

被折叠的 条评论
为什么被折叠?



