Originally posted by Jose Botella:
Welcome to the Ranch tangi.
JLS 188.8.131.52 says that methods are not checked for forwarding referecences on fields. Also notice that in "return i=100;" the access to "i" occurs in the left hand side of an assignment. Thus the compiler should not complain even if the expression were placed in an instance field initialization code:
184.108.40.206 Restrictions on the use of Fields during Initialization
The declaration of a member needs to appear before it is used only if the member is an instance (respectively static) field of a class or interface C and all of the following conditions hold:
* The usage occurs in an instance (respectively static) variable initializer of C or in an instance (respectively static) initializer of C.
* The usage is not on the left hand side of an assignment.
* C is the innermost class or interface enclosing the usage.
There are 12 assignment operators; all are syntactically right-associative (they group right-to-left). Thus, a=b=c means a=(b=c), which assigns the value of c to b and then assigns the value of b to a.
At run time, the result of the assignment expression is the value of the variable after the assignment has occurred. The result of an assignment expression is not itself a variable.