---
spec: JLS
title: "The Java Language Specification"
edition: "Java SE 14 Edition"
java_version: 14
chapter: "Chapter 14. Blocks and Statements"
section: "14.17"
heading: "14.17. The return Statement"
parent: "Chapter 14. Blocks and Statements"
source: https://docs.oracle.com/javase/specs/jls/se14/html/jls-14.html#jls-14.17
id: "14.17"
url: https://jvm.obfuscated.software/jls/se14/14.17.html
raw: https://jvm.obfuscated.software/jls/se14/14.17.md
---

# 14.17. The `return` Statement

A `return` statement returns control to the invoker of a method ([§8.4](8.4.md), [§15.12](15.12.md)) or constructor ([§8.8](8.8.md), [§15.9](15.9.md)).

```
ReturnStatement:
  return [Expression] ;
```

There are two kinds of `return` statement:

- A `return` statement with no value.
- A `return` statement with value *Expression*.

A `return` statement attempts to transfer control to the invoker of the innermost enclosing constructor, method, or lambda expression; this enclosing declaration or expression is called the *return target*. In the case of a `return` statement with value *Expression*, the value of the *Expression* becomes the value of the invocation.

It is a compile-time error if a `return` statement has no return target.

It is a compile-time error if the return target contains either (i) an instance or static initializer that encloses the `return` statement, or (ii) a `switch` expression that encloses the `return` statement.

It is a compile-time error if the return target of a `return` statement with no value is a method, and that method is not declared `void`.

It is a compile-time error if the return target of a `return` statement with value *Expression* is either a constructor, or a method that is declared `void`.

It is a compile-time error if the return target of a `return` statement with value *Expression* is a method with declared return type T, and the type of *Expression* is not assignable compatible ([§5.2](5.2.md)) with T.

Execution of a `return` statement with no value always completes abruptly, the reason being a return with no value.

Execution of a `return` statement with value *Expression* first evaluates the *Expression*. If the evaluation of the *Expression* completes abruptly for some reason, then the `return` 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 being a return with value `V`.

If the expression is of type `float` and is not FP-strict ([§15.4](15.4.md)), then the value may be an element of either the float value set or the float-extended-exponent value set ([§4.2.3](4.2.3.md)). If the 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.

It can be seen, then, that a `return` statement always completes abruptly.

The preceding descriptions say "attempts to transfer control" rather than just "transfers control" because if there are any `try` statements ([§14.20](14.20.md)) within the method or constructor whose `try` blocks or `catch` clauses contain the `return` statement, then any `finally` clauses of those `try` statements will be executed, in order, innermost to outermost, before control is transferred to the invoker of the method or constructor. Abrupt completion of a `finally` clause can disrupt the transfer of control initiated by a `return` statement.
