return statement in Java

return statements are jumping statements which ends the method of non void return types and returns the control to the point of calling with a value.

It is only used in functions or methods.

General Syntax for a method

return_type method_name(parameterlist){

//statements

//return value;

}

Return type is simply a datatype of the value which should be returned to the point where it's method is called when that method is completed executing.

Example

int addition(int a, int b){

int sum=a+b;

return sum;

}

We can call by its name with suitable parameters. For eg. addition(2,3);

We can get or store the returned value by assigning the method to a suitable variable. For eg. int value=addition(2,3); where value=5 here.