0
What is diffrence between exit(0) and exit(1) in java through program
Tell by program
3 Réponses
+ 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.
+ 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.
+ 1
exit(0) is use to terminate from program and exit(1) is used for terminate when error occur