title: Terminating a Java Program
body: <p>I found out ways to terminate (shut-down or stop) my Java programs.  I found two solutions for it.</p>
  <ol>
  <li><p>using <strong>return;</strong><br/>When I want to quit or terminate my program execution , I add this.</p>
  </li>
  <li><p>using <strong>System.exit()</strong> ; <br> Sometimes I used it. I read about <strong>System.exit()</strong> from <a href="https://stackoverflow.com/questions/3715967/when-should-we-call-system-exit-in-java">this question</a>.</p>
  </li>
  </ol>
  <p>So, I know a little on both them. But I am still confused as to how they actually work. Please check below codes...<br/></p>
  <pre><code>public class Testing {
  
  public static void main(String... str) {
      System.out.println(1);
      System.exit(0);
      System.out.println(2);
      return;
   }
  }
  </code></pre>
  <p>I am sure that <strong>2</strong> will not appear. I would like to know is why <code>return;</code> or other codes can write below the statement of <code>System.exit(0);</code> and what was real definition for <code>return;</code> (<em>because it is strange thing for me <code>return</code> without any variables or values</em>) ?</p>