Originally posted by CornedBee
Actually the only call-by-value behavior in Java is for primitives, everything else is passed by reference (as there are only references in Java).
C has call by value or by reference (using pointers).
C++ has call by value or by reference (using either pointers or references).
I didn't expect to find this misconception here. The only parameter passing mechanism in Java is by value. Period. Pass by reference was considered error prone and ruled out by the founders of Java. C also has call by value only. Passing a pointer (reference) by value is NOT the same as pass by reference.
If you need the efficiency of not copying the vector, pass one in.
That's one possibility. The other one is to create a new vector on the heap in the function and then return a pointer to it.