Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Basically, there are four answers:</p> <ol> <li><p>Because that's the way it was designed. Yea, I know that's a circular reason. But the point is that this is the way it is and it ain't going to change. So unless you are planning on designing your own language, the question is moot.</p></li> <li><p>Cleanness of design (aka the DRY principle). Don't specify two entry point signatures when one can do the job. And clearly, it can.</p></li> <li><p>Semantic simplicity. Suppose (hypothetically) that Java <em>did</em> support both <code>void main(String[])</code> and <code>void main()</code> entry points. What would happen if a class defined both methods? Is that an error? If not, which one takes precedence when there is ambiguity? Is this confusing yet?</p> <p>By only allow <code>void main(String[])</code>, the JLS avoids the problem.</p></li> <li><p>This is analogous to the standard C and C++ entrypoint signatures. (Admittedly, some C / C++ runtimes support other non-standard entrypoints as well ... but that's not exactly a good thing ... IMO.)</p></li> </ol> <p>None of this means that it would have been unambiguously wrong to do it another way. And for example C# gives you alternative signatures, and deals with the ambiguity problem by requiring the developer to designate an entry point some other way. </p> <p>FWIW, <a href="http://en.wikipedia.org/wiki/Main_function" rel="noreferrer">this wikipedia page</a> describes the "main" method in a number of languages.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload