This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes String args[ ] in main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "String args[ ] in main " Watch "String args[ ] in main " New topic

String args[ ] in main

Krishnamurthy Rajagopal

Joined: Feb 05, 2001
Posts: 2
I am new to java and when I analyzed the command line
public static void main(String args[ ]){
I found that any modifier works fine(came to know through java ranch discussions that it is already registered as a bug).I found convincing answers for static and void too. But what bewilders me is why one has to pass String args[ ] parameter in the main method even when one does not make use of it. It makes sense when I am using command line to pass arguments but why should it be made mandatory parameter for all programs. Is there any rationale behind it?
Thanks in advance
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4340

They probably didnt want to overload main().
That way the JVM calls the same method for every class.
As you know, you dont have to pass any arguments if they arent needed.
[This message has been edited by Randall Twede (edited February 05, 2001).]

Visit my download page
Krishnamurthy Rajagopal

Joined: Feb 05, 2001
Posts: 2
Hi Randall!
Thanks for the answer.
It is sorta covered in the JavaRanch Style Guide.
subject: String args[ ] in main
Similar Threads
Why it is not 'null' ?
how to read character from command line and store it string
parseInt Question.......
Using multiple command line arguments to open multiple files