Can Unchecked Exceptions be converted into Checked Exceptions in Java? If yes, please suggest ways to convert/wrap an Unchecked Exception into a Checked Exception.
How to convert / wrap Unchecked Exceptions into Checked Exceptions in Java?
1k views Asked by Randhish kumar At
2
Yes. You can catch the unchecked exception and throw a checked exception.
Example :
Then, in the constructor of the checked exception, you call
initCause
with the passed exception :