The return statement is used to return from a method.

The return statement immediately terminates the method in which it is executed.

 
public class Main {
  public static void main(String args[]) {
    boolean t = true;
    System.out.println("Before return");
    if (t)
      return; // return to caller
    System.out.println("after");
  }
}

The output from this program is shown here:


Before return
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.