This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
The main() method is much less "magic" than beginners often imagine. It is just a public static method of a class, like any other. All the things that apply to any other public static method also apply to main().
The only thing that is special about main() is that the standard Java launcher calls it when starting an application.
The standard Java launcher will only call a public static method with the name "main" and accepting a String array. Other methods called "main" are allowed, but the standard Java launcher will ignore them. That said, it is generally bad practice to name any method "main" unless it is to be used as the application entry point.
I keep referring to the "standard Java launcher" because there are in fact many ways of starting Java code. For instance, applets are not started via main(), but have a life-cycle involving methods called init(), start(), stop() and destroy(). Also, you can write your own launcher in native code (e.g. C++), to start Java code in any way you like; this involves Java Native Interface and Java Invocation Interface. [ August 14, 2006: Message edited by: Peter Chase ]
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
It is possible to overload the main function in java. But the trick is that JVM will look for public static void main(String args) to load the class firstly. Once it finds the main with this signature, you can have other main functions being called within the same class. Make sure you change the input parameters to the main while overloading as the return type change wont help.
Rahul Sudip Bose wrote:so, is overloading of main() not useful for any purpose and is just a trick ?
Let's put it this way: I don't have any use for it. And apparently you don't either. But there are several million users of Java. I'm not prepared to say that absolutely none of those millions of users have any use for it.
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com