And when you have clarified your understanding about that topic, I would recommend you recast your question into a question about what you wanted to do, rather than a question about something you already chose which didn't do that anyway.
You're probably thinking of defensive copying. You can't reference objects directly in Java: you have to use a reference variable, which is just a memory address that sits on the stack. It gets passed by value when you use it as the argument in a method; however this value is still the address of the object, so if you do anything with the new reference variable you'll still be pointing at the same object, giving the appearance of having passed the object itself by reference.
If your method involves altering the input object to produce a result (sorting a list, for example), but you don't want to change the original, you'd make a copy within the method. If your class supports it (most in the standard API do) you can call the clone() method - although cloning should generally be avoided. Some objects (collections especially) have constructors that can take another instance and make a copy. The way you make the copy in general depends on the object's concrete type.
E.g. (ignore the generics if you want - it just means we can use the method on any list that we can sort)
will give the result
[10, 12, 3, 4, 5]
[cod, mouse, zebra, emu]
But if you don't make the copy and instead run the sort on the reference that was passed, i.e.you'll find we've inadvertently changed the argument we passed in get the result
[3, 4, 5, 10, 12]
[cod, emu, mouse, zebra]
because the reference "a" still points to the original object.
This problem can be overcome by using immutable objects, which is the default for functional languages. However, Java doesn't really do immutable.
Justin van Wilgen wrote:I know in java things are normally passed by reference, ...
That's wrong - in Java, method arguments are always passed by value, and never passed by reference.
Many people are confused by this, because variables of non-primitive types are references in Java. When you pass such a variable to a method, it is still passed by value - but you are passing a reference by value; in other words, a copy of the reference is made. But passing a reference by value is not the same as passing by reference!