What this statement do "system.exit(x)"? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

What this statement do "system.exit(x)"?

I saw a question in which first a value is assigned to X and then come this statement "system.exit(x)" System.out.println(X)

16th Jun 2019, 4:02 PM
Luminous Priest
Luminous Priest - avatar
2 Answers
+ 7
System.exit() method exits current program by terminating running Java virtual machine. This method takes a status code. Here X is a status code. If X = 0 means it will terminate successfully. if X = 1 or -1 or any other non-zero value– Generally indicates unsuccessful termination
16th Jun 2019, 5:23 PM
A͢J
A͢J - avatar
+ 1
Thanks
16th Jun 2019, 5:36 PM
Luminous Priest
Luminous Priest - avatar