A method can compute and return a value to its calling
statement specifies an expression whose type must match the return
type specified for the method and whose value is computed and returned
to the calling program.
As an example, consider the return statement in
, which computes and returns the Euclidean distance between the x-y
coordinates received from the calling program. The control flow (see
the arcs labelled 1-5) proceeds as follows:
returnstatement, which passes control back to the calling program,
diameterand proceeds on through the calling program.