|
|
|
|
|
by twic
3529 days ago
|
|
Kind of. When i see a method reference like this: someExpression()::methodName
I mentally rewrite it into: getMethodReference(someExpression(), "methodName")
Where there is some fictional getMethodReference function that takes an object and a method name, and creates a reference. It works like this even when someExpression() is just a reference to a variable.In the rewritten form, someExpression() gets fully evaluated before getMethodReference is called, producing a value, and it's that value which is used to create the reference. As you suggested, it works like that because Java is pass-by-value. If Java was pass-by-reference, then someExpression() would produce a reference to a variable instead of a value, and the reference could somehow be based on that variable. But it doesn't, so it's not. |
|