What will happen if you put System.exit(0) on try or catch block? Will finally block execute? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What will happen if you put System.exit(0) on try or catch block? Will finally block execute?

13th Aug 2017, 9:34 AM
Safinaz Sayed
Safinaz Sayed - avatar
2 Answers
+ 6
The finally block will not execute if System.exit(0) is called (since the Java VM exits when that statement is called).
13th Aug 2017, 9:36 AM
Dev
Dev - avatar
+ 2
ok ,thanks.
13th Aug 2017, 9:38 AM
Safinaz Sayed
Safinaz Sayed - avatar