How can we know which type of Exception it is? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How can we know which type of Exception it is?

How can we know or guess that which type of Exception it is, now I am completing some tasks about Exceptions but for me it is getting difficult to find them. Is there any easier way of knowing them

5th Sep 2020, 8:03 AM
Umidbek
Umidbek - avatar
2 Answers
+ 1
You can use instanceof method to check if object is ancestor of specific class. Also you can use exception.getCause() method to ses the cause of exception.
5th Sep 2020, 9:57 AM
Artem
+ 1
Thank you Artem
5th Sep 2020, 11:42 AM
Umidbek
Umidbek - avatar