java return statement :

  • Return statement in used to explicitly return from a method. Return causes program control to transfer back to the caller of the method.
  • The return statement immediately terminates the method in which it is executed.

Syntax:

return;
Here is an example to demonstrate
return :
    class ReturnDemo {
        public static void main(String[] args) {
            boolean t = true;
            System.out.println("Silan");
            if (t)
                return;
            System.out.println("it will not execute");
        }
    }

Output

 

Silan

Our Services:

Java Training | Python Training | Machine Learning with Python Training | Deep Learning with Python Training | Data Science with Python Training | Projects

Silansoftware Pvt.Ltd, BBSR
Call to: 0674-2361252

Comment