Java: Use of System.exit() and purpose of (String [] args) in the main method
<p>What is the use of <code>System.exit()</code>? What happens if I don't use it? My professor used it in the following way:</p>

<pre><code> public static void main(String[] args) throws Exception {

    // make sure that you have the right number of arguments
    if (args.length != 1) {
      System.out.println("Usage: java FileDemo filename");
      System.exit(0);
    }
</code></pre>

<p>I don't know why he used it. Also I don't get why he asked me to make sure that I have right number of arguments. How does he know if <code>(args.length !=1)</code> ? We have not yet populated <code>String [] args</code> in the main method.</p>