Mega Code Archive

 
Categories / Java Book / 001 Language Basics
 

0064 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