Do you know Exception Handling? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Do you know Exception Handling?

i don't know

21st Dec 2016, 3:12 PM
Trianstagram
Trianstagram - avatar
2 Answers
+ 1
You can catch exceptions in Java with: try { // all the code where the exception could happen and you want to catch it } except (Exception e) { // what you want to execute when the exception actually happens } Notice how I put Exception after except. Exception class is the base class of all exceptions. The above will catch any exception. If you wanted to (for example) catch FileNotFoundException, you would put that instead of Exception above.
21st Dec 2016, 3:28 PM
DefaltSimon
DefaltSimon - avatar
+ 1
tanks master
21st Dec 2016, 3:30 PM
Trianstagram
Trianstagram - avatar