Java Reference
In-Depth Information
14.17. The
return
Statement
ReturnStatement:
return
Expression
opt
;
A
return
statement is
contained
in the innermost constructor, method, or initializer whose
body encloses the
return
statement.
It is a compile-time error if a
return
statement is contained in an instance initializer or a
A
return
statement with no
Expression
must be contained in a method that is declared, using
time error occurs.
A
return
statement with no
Expression
attempts to transfer control to the invoker of the
method or constructor that contains it. To be precise, a
return
statement with no
Expression
always completes abruptly, the reason being a return with no value.
A
return
statement with an
Expression
must be contained in a method declaration that is de-
clared to return a value (§
8.4
), or a compile-time error occurs.
The
Expression
must denote a variable or value of some type
T
, or a compile-time error
occurs.
compile-time error occurs.
A
return
statement with an
Expression
attempts to transfer control to the invoker of the
method that contains it; the value of the
Expression
becomes the value of the method in-
vocation. More precisely, execution of such a
return
statement first evaluates the
Expres-
sion
. If the evaluation of the
Expression
completes abruptly for some reason, then the
re-
turn
statement completes abruptly for that reason. If evaluation of the
Expression
completes
normally, producing a value
V
, then the
return
statement completes abruptly, the reason be-
ing a return with value
V
.
expression is of type
double
and is not FP-strict, then the value may be an element of either
the double value set or the double-extended-exponent value set.