This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes Send answer to my dout ie difference b/w System.exit(0) and System.exit(1) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Send answer to my dout ie difference b/w System.exit(0) and System.exit(1)" Watch "Send answer to my dout ie difference b/w System.exit(0) and System.exit(1)" New topic
Author

Send answer to my dout ie difference b/w System.exit(0) and System.exit(1)

nagaraju parepally
Greenhorn

Joined: Aug 04, 2005
Posts: 2
Hai,
What is the difference b/w System.exit(0) and System.exit(1)?
I am little bit dout on >>> operator plz clarify my dout
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9044
    
  10
System.exit(0) does the same thing as System.exit(1)
It is a command that stops the entire JVM
Unless you are calling the program with a bat file and do something with the return value of the program, it makes no difference which one you use.


JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Steve McCann
Ranch Hand

Joined: Oct 20, 2004
Posts: 81
The integer is returned as an exit code. The convention is to return 0 i.e. System.exit(0) if the application terminated correctly (without any errors). If you want to return any other number for reporting errors/exeptions to outside the program you can do this with something like...


Hope this makes sense.
Steve
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11250
    
  16

System.exit(<some integer> is a function call like anything else. you're saying "Shut down the JVM, and pass the integer value to the OS.

by using different values, you can signal WHY the JVM was shut down. The values have no inherent meaning, but customarily 0 means "everything was just fine". any other value means something bad happened, but that's for you to determine when you write the code.


There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Barry Gaunt
Ranch Hand

Joined: Aug 03, 2002
Posts: 7729
As I explained to you (nagaraju) before, please keep unrelated questions in separate topics.

I am little bit dout on >>> operator plz clarify my dout


Create a new topic for the above question. And say what exactly you do not understand about the ">>>" shifting operator. I you have read something about the operator, and you do not understand it, then quote what you have read.


Ask a Meaningful Question and HowToAskQuestionsOnJavaRanch
Getting someone to think and try something out is much more useful than just telling them the answer.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Send answer to my dout ie difference b/w System.exit(0) and System.exit(1)