aspose file tools*
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
Author

Main method

Sen George
Ranch Hand

Joined: Sep 21, 2005
Posts: 76
Is the parameter String[] in the main method of a public class required by language design or is it based on other logic?

Please advise.
Leandro Melo
Ranch Hand

Joined: Mar 27, 2004
Posts: 401
Hello.

Regarding the main method which is the entry point of the application, the String[] argument is required because of a design choice. It's just a standard way to pass input arguments to the application.


Leandro Melo
SCJP 1.4, SCWCD 1.4
Bob Ruth
Ranch Hand

Joined: Jun 04, 2007
Posts: 320
Yeah, I think it just comes from a long LONG legacy with C. When you type in parameters they are often treated as character groups....or... words. And an easy way to pass those is as strings in an array.


------------------------
Bob
SCJP - 86% - June 11, 2009
Kaydell Leavitt
Ranch Hand

Joined: Nov 18, 2006
Posts: 689

Is the parameter String[] in the main method of a public class required by language design or is it based on other logic?


Java allows overloading of methods. To determine a method signature the name of the method must match and the type and the order of the parameters must match. For a main method to be an entry-point, it must be called "main" and the paramter list must be one parameter, a String array for the main method to be eligible to be an entry-point.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Main method