LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Java: System.exit(0) vs. System.exit(1) (https://www.linuxquestions.org/questions/linux-newbie-8/java-system-exit-0-vs-system-exit-1-a-882067/)

narayanan02 05-22-2011 04:11 AM

Java: System.exit(0) vs. System.exit(1)
 
give answer for this question in detail

MTK358 05-22-2011 08:33 AM

The exit code of a program basically says if it succeeded. 0 usually means success, and another number means faliure.

This is very useful in command-line applications. The bash shell uses it to enable you to do stuff like this:

Code:

# run command2 only of command1 is successful
command1 && command2

# run command2 only if command1 failed
command1 || command2

# run command2 and command3 over and over while command1 succeeds
while command1
do
    command2
    command3
done



All times are GMT -5. The time now is 07:33 PM.