Java-Return

Return

The return statement is used to explicitly return from a method. The return statement immediately terminates the method in which it is executed. For example:

As you can see, the final println( ) statement is not executed. As soon as return is executed, control passes back to the caller.

Program

1

Program Source

class Javaapp {

    public static void main(String[] args) {
        
        System.out.println("Before return");
        return;
        System.out.println("After return");
    }
}

Leave a Comment