• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

String args[ ] in main

 
Krishnamurthy Rajagopal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
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
krish
 
Randall Twede
Ranch Hand
Posts: 4439
3
Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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).]
 
Krishnamurthy Rajagopal
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Randall!
Thanks for the answer.
krish
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic