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 String args[ ] in main Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
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: 4351

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.
I agree. Here's the link:
subject: String args[ ] in main
It's not a secret anymore!