The return statement in Java is always closely related to the method, which is always used in the method, has two functions, one is the value that returns the specified type of the method (this value is always determined), and one is the execution of the End method (only a return statement).
In the various articles in the return statement, most of the returns statements are only used in methods that have returned values (not void return values). There is little or no introduction to the use of return statements in the Vodi value method.
The return statement is used in a method that is not a void return value type, not only for returning the base type, but also for returning (including the user-defined Class) object.
One: The return statement is always used in the method and has two effects:
One is the value of the specified type of the return method (this value is always determined),
One is the execution of the End method (just a return statement).
Two:
Instance 1--Returns a string
private string gets () {
string s = ' qw789 ';
return s;
}
Instance 2--End Program
private void gets (String s) {
if (s = = null) {return
;
}
System.out.println ("haha");
}
The above two kinds of examples for you to introduce the use of return in Java, I hope to help you.