The brain complements the basics, the use of return.
There are two common functions of return:
The first usage is to return the keyword used for the parameter, and if a method with a return value is executed, it needs to return a parameter, example:
public = "abc"; return A;}
Then this method is called and returns a string with the value ABC, which is called the following example:
string result = FunctionTest ();
The main reason is to remember the second usage:
The second usage is that the code executes here to terminate.
For example, when the code executes to a certain place there will be several results, and then one of the results can not execute the subsequent code, when there is a return to terminate the subsequent code execution. The following example:
if ("1". Equals ("1")) { System.out.println ("Hello!") ); return ; } System.out.println ("You are also good");
After the code has gone through the IF statement, the second statement does not output.
The function of return in Java