return
expression;
On the other hand,
for a void type of method that does not return any value,
the following
syntax
is used:
return;
A return statement unconditionally transfers control to the calling method from the called
method. This means that all statements between the return statement and the end of the
method are skipped.
That is why such a statement is normally placed at the end of a method; it is
also possible to use it when specific conditions apply and an early termination is required.
Using a
return statement at the end of the method is essential in the case of methods that return a type
Do'stlaringiz bilan baham: |