0

What is diffrence between exit(0) and exit(1) in java through program

Tell by program

16th Nov 2016, 2:28 PM
murari
3 Respuestas
+ 2
System.exit(0) means it is a normal exit from a program.But System.exit(-1) means the exit may be due to some error. Any number other that zero means abnormal exit.
16th Nov 2016, 4:29 PM
Vishal Koshti
Vishal Koshti - avatar
+ 2
Acutally, there is no real difference at all. It does the same. The real difference is, somebody who started the program (can be a other program too) can read this value after your program terminates. Its called a return value. Your program returns this value upon termination. This is useful to determine if your program run normally or if there where any errors. But if 0 means error or -1, 1, 2... etc. is your decision. There is however some common understanding on this subject, which murari and vishal already mentioned.
18th Nov 2016, 1:25 PM
Roland
+ 1
exit(0) is use to terminate from program and exit(1) is used for terminate when error occur
16th Nov 2016, 2:29 PM
murari