In Java everything is returned by value. That includes references and here’s where the confusion is!
If I have:
Trade t = new Trade();
then t
is a reference (we’d say it is-a Trade, but that refers to the type. t
really is a reference). When I return that from a method, I’m returning the reference, by value. The reference still points to that original object.
Hence if I return that t
from a method and then invoke a further method on it, it invokes the method on the Trade
that it originally pointed to.