This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

returning int from the main....

 
abhishek kunal
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
cant we return int from main function of a class...so the main method's signature w'd look like public static int main(String args[]), i ahve done it, but it shows a problem, NoSuchMethodError . isn't there any way to overcome this limitation???
 
Henry Wong
author
Marshal
Pie
Posts: 20836
75
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, what do you expect the application to do with the int that is returned?

If you are expecting it to return as the exit code, as in a C application, then you can accomplish the same thing with using the system exit() method. The parameter passed to the exit method is the exit code.

Henry
 
Praveen Sangolli
Greenhorn
Posts: 28
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
JVM is the one that calls the main method and what will the JVM do with the int that you return. No you cannot change the method signature for public static void main(String args[])
 
abhishek kunal
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hmmm, so main method doesn't provide this, we have to achieve this by System.exit(), while it was possible by both ways in c++......anyways tx!!
 
abhishek kunal
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
gud!! tx !!
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Pie
Posts: 15150
31
Android IntelliJ IDE Java Scala Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abhishek kunal wrote:... while it was possible by both ways in c++......

Yes, but Java is not C++, there's no reason why it should be the same in Java as it is in C++.
 
Campbell Ritchie
Sheriff
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
abhishek kunal wrote:gud!! tx !!
Please don't write gud, tx, or similar.
 
abhishek kunal
Ranch Hand
Posts: 42
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ohh i am very sorry, it was polite and humble from my side...please don't take it other way...
 
Campbell Ritchie
Sheriff
Pie
Posts: 47274
52
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies accepted. I knew what you meant, but other people who didn't grow up speaking English might not.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic