Originally posted by geo yo:
. . . objects are passed by reference.
No they aren't. There is a very easy rule in
Java to remember what is passed by reference . . .
Nothing.
There is no such thing as pass-by-reference in Java. Everything is passed by value. If you do a search in the Ranch you find old threads like
this one where other people got confused about pass by value and pass by reference. Please look at that
thread and its included links.
But to repeat: there is no such thing as pass by reference in Java.
When you look through that old thread and its links you find there are some languages where there is true pass-by-reference; you can alter the contents of the reference passed. In the case of Java, when passing objects, you cannot change the reference passed, at all. The object in that reference will always be the object in that reference and a called method cannot change it however hard it tries.
But if use the value passed to gain access to a mutable object you can call methods on that object which change its state. That is what you are actually doing.
And I don't understand the bit about static methods having higher priority; it doesn't sound correct to me, I am afraid.