title: Which method is used to terminate the execution of Java program in between?
body: <p>We used functions like exit() in C++ to abnormally terminate the execution of program, which function can we use in Java.
  For ex :- In following program I want to terminate the execution as soon the value of i is printed for 1st time.</p>
  
  <pre><code>//following is the program :  
  class Lcm {
          public static void main( String args[] ) {
  
              int a = Integer.parseInt( args[0] );
              int b = Integer.parseInt( args[1] );
  
              for ( int i=1 ; i&lt;=a*b ; i++ ) {
                  if ( i%a==0 &amp;&amp; i%b==0 ) {
                      System.out.println( "lcm is: " + i );
                      /* i want to terminate the program
                       * when the value of i is printed
                       * for very 1st time
                       */
                  }
              }
          }
      }
  }
  </code></pre>