Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>That would be the <code>main</code> method.</p> <p>It should be declared as</p> <pre><code>public static void main(String[] args) </code></pre> <ul> <li>It needs to be <code>public</code>, since the JVM should have access to call the method.</li> <li>It needs to be <code>static</code>, as no objects are instantiated when the program starts</li> <li>It takes an array of <code>String</code>s as argument (coming from the command-line)</li> </ul> <p>Some good links to have a look at:</p> <ul> <li><a href="http://download.oracle.com/javase/tutorial/getStarted/application/index.html#MAIN" rel="nofollow noreferrer">The main Method (from the official Getting started trail)</a></li> <li><a href="http://www.java-tips.org/java-se-tips/java.lang/what-is-the-main-method.html" rel="nofollow noreferrer">What is the main method</a></li> <li><a href="https://stackoverflow.com/questions/261428/entry-point-for-java-applications-main-init-or-run">Entry point for Java applications: main(), init(), or run()?</a></li> </ul> <hr> <p>Some people may recommend you to write</p> <pre><code>public static void main(String... args) </code></pre> <p>this is equivalent to <code>String[] args</code> <em>if</em> you're using a compiler of version 1.5 or later. (I would discourage this unless you're extensively calling your <code>main</code> method internally with a varying number of arguments.)</p> <p>Others may suggest</p> <pre><code>public static void main(String args[]) </code></pre> <p>This is also equivalent, but discouraged by the <a href="http://www.oracle.com/technetwork/java/codeconv-138413.html" rel="nofollow noreferrer">Java Coding Convention</a>.</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