difference between System.exit(0) and System.exit(-1) [duplicate]
This question already has an answer here: Difference in System. exit(0) , System.exit(-1), System.exit(1 ) in Java 11 answers Can any one share to me difference between System.exit(0) and System.exit(-1) it is helpful if you explain with example. It's just the difference in terms of the exit code of the process. So if anything was going to take action based on the exit code (where 0 is typically success, and non-zero usually indicates an error) you can control what they see. As an example, take this tiny Java program, which uses the number of command line arguments as the exit code: public