Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
clone()如果遇到 CloneNotSupportedException ,调用者如何恢复?为什么它是一个检查异常?
clone()
为什么它是一个检查异常?
我怀疑答案是真的:“因为当 Java 刚问世时,很少有人知道什么时候检查异常是有意义的。” 那时,他们没有有效的 Java :)
有很多这样的事情 - 检查但可能不应该检查的异常,以及未检查但应该检查异常的情况......Integer.parseInt抛出NumberFormatException可能是最清楚的例子。
Integer.parseInt
NumberFormatException