Given the following function call in C
:
fooFunc( barFunc(), bazFunc() );
The order of execution of barFunc
and BazFunc
is not specified, so barFunc()
may be called before bazFunc()
or bazFunc()
before barFunc()
in C
.
Does Java
specify an order of execution of function argument expressions or like C
is that unspecified?
In a method or constructor invocation or class instance creation expression, argument expressions may appear within the parentheses, separated by commas. Each argument expression appears to be fully evaluated before any part of any argument expression to its right.
The formal parameters are specified as a list, so for "the formal parameter types of M and N" to be the same, they must be the same list and lists are order-dependant. Since the correspondance in 3 is order dependent, the order of type parameters also matters.
An example would be ADD : ADD(1,2) and ADD(2,1) can be used interchangeably, the order of parameters does not matter.
The order of the parameters make a difference because it is a different signature. Imagine you had a human signature and altered the order of the letters, it would no longer be the same signature.
From the Java Language Specification (on Expressions):
15.7.4 Argument Lists are Evaluated Left-to-Right
In a method or constructor invocation or class instance creation expression, argument expressions may appear within the parentheses, separated by commas. Each argument expression appears to be fully evaluated before any part of any argument expression to its right.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With