Parameters in Java are always passed by value. Primitives (like integer in your sample) passed in the function are modified inside, but passed value of actual parameter appears not modified after return. In your example, you need to return o as a return value.
As object (of classes) are reference object, passing them by value means their references are passed by value, so the object itself behaves like if it is passed by reference in C++. If you pass such object to Java function and modify it there, after return it appears modified.
I know excellent article explaining all that very well:
http://www.yoda.arachsys.com/java/passing.html[
^].
—SA