The JLS, Java SE 7 Edition has the following example, which says it's fooFunc()
before bazFunc()
, however I can only find the example - I haven't yet found the associated statement that specifies it:
Example 15.12.4.1-2. Evaluation Order During Method Invocation
As part
of an instance method invocation (§15.12), there is an expression that
denotes the object to be invoked. This expression appears to be fully
evaluated before any part of any argument expression to the method
invocation is evaluated. So, for example, in:
class Test2 {
public static void main(String[] args) {
String s = "one";
if (s.startsWith(s = "two"))
System.out.println("oops");
}
}
the occurrence of s
before ".startsWith"
is evaluated first, before
the argument expression s = "two"
. Therefore, a reference to the
string "one"
is remembered as the target reference before the local
variable s is changed to refer to the string "two"
. As a result, the
startsWith
method is invoked for target object "one"
with argument
"two"
, so the result of the invocation is false, as the string "one"
does not start with "two"
. It follows that the test program does not
print "oops"
.
fooFunc()
, thanbazFunc()
, at lastbarFunc()
– Lotta