Sunday, 4 December 2016

Why Class CloneNotSupportedException is a checked Exception?

java.lang.CloneNotSupportedException - A Checked Exception

If the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.

Why is it a checked Exception?
It was developed in earlier phase of the Java, there was very little experience of when it would make sense for an exception to be checked.

Some exceptions which are checked but probably shouldn't be and occasions where the exception is unchecked but should be checked.
Integer.parseInt throwing NumberFormatException probably being the clearest example.



No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...