Why throwing user defined Exception need to be in Try catch block ? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Why throwing user defined Exception need to be in Try catch block ?

But throwing predefined Exception need not to be in try catch block ?

28th Mar 2020, 3:54 PM
Programmer Raja
Programmer Raja - avatar
1 Answer
+ 3
A simple answer would be that every user defined exception is a checked exception and every checked exception must be handled in Java whether using the try catch block or by using the throws keyword.
28th Mar 2020, 4:51 PM
Avinesh
Avinesh - avatar