1
0

Return Statement in Java

The last of the branching statements is the return statement. The return statement exits from the current method, and control flow returns to the statement where the method was invoked. The return statement has two forms: one that returns a value, and one that doesn’t. To return a value, simply put the value (or an expression that calculates the value) after the return keyword.

return ++count;

The data type of the returned value must match the type of the method’s declared return type. When a method is declared void, use the form of return that doesn’t return any value as.

return;

Leave a Reply