• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

String args[ ] in main

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 4716
9
Scala Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Randall!
Thanks for the answer.
krish
 
reply
    Bookmark Topic Watch Topic
  • New Topic