Try catch block | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Try catch block

Why doesn't the try catch block catch this exception?.... shouldn't it catch all exceptions? https://code.sololearn.com/cZfqMiLLcx1H/?ref=app

21st Oct 2020, 11:10 AM
Sheldon 10110
Sheldon 10110 - avatar
4 Answers
+ 4
Because the compiler catch it first. catch will catch exceptions at runtime.
21st Oct 2020, 11:12 AM
QTWizard
0
Why is this?
21st Oct 2020, 11:13 AM
Sheldon 10110
Sheldon 10110 - avatar
0
Just search for the difference between compile errors and runtime errors and you will find an answer.
21st Oct 2020, 11:15 AM
QTWizard
0
Aaaaah I hadn't seen the runtime part...thanks... I get it now
21st Oct 2020, 11:23 AM
Sheldon 10110
Sheldon 10110 - avatar