How to use the return keyword in Java?
The return keyword is used to return from a method when its execution is complete. When a return statement is reached in a method, the program returns to the code that invoked it.
A method can return a value or reference type or does not return a value. If a method does not return a value, the method must be declared void and it doesn't need to contain a return statement.
If a method declare to return a value, then it must use the return statement within the body of method. The data type of the return value must match the method's declared return type.