The return statement

The return statement is used to return from a method. A method can have either a return value of some type, or it can have a return type of void (which means it returns nothing).

If we want to return from a method that actually should return a value, the value is specified right after the return statement. The data type of the return value must match the data type in the declaration of the method.

If the method has a return type of void, simply return; will be used to exit the method.
Here are two examples:

Search for more Java info on this site here:
Custom Search

Please type any questions here.