File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Main method Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Main method" Watch "Main method" New topic

Main method

Willie Toma
Ranch Hand

Joined: May 11, 2001
Posts: 78
Is this correct?
The main method can be something other than void, as long as there is a main method that is void.
Can a main method be anything thing as long as there is a void method?
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
Yes, you can. If you by that mean if you can overload main

Note! You can have the same parameter in the header. That is your overloaded main can take String args[]. Overloaded method must have diffrent parameterlist
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
To start an application, the class you type after java,i.e.
java ClassName
must have a method with the signature
public static void main( String[] args )
or it won't start.
But you may have another method named main with different parameters (overloading main) if you wish. For instance
private static int main( String s )
double main( int i )
No problem.

[This message has been edited by Marilyn deQueiroz (edited September 22, 2001).]

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: Main method
It's not a secret anymore!