return statement returns 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
Home 
  Java Book 
    Language Basics  

Statement:
  1. Simplest if statement
  2. If else statement
  3. switch statement
  4. while loop
  5. do-while statement
  6. for Loop
  7. for each loop
  8. break to Exit a Loop
  9. continue
  10. return statement returns from a method.
  11. Comments