To invoke a method, one requires a variable that points to an object (e.g., only given a variable like
o can one call a method:
One needs a variable to invoke a method
CorrectionHere is what's right.
One can invoke a method on an object without the reference to that object being stored in a variable. All that is needed is that the expression in front of the ”.” of the call evaluates to an object reference.
For example, one can do method chaining on a normal method:
get().m(); // assuming get() returns an object
Or one can do method chaining on a constructor:
Or one can call a method on an
Or one can call a method on an object one gets out of an array: