Discussion in 'Computer Science & Culture' started by Ender, Jan 6, 2004.
In Java when you pass a vector, do you really pass the vector, or a copy or what?
Log in or Sign up to hide all adverts.
Everything except the primites (char, int, double, float, etc) can be thought of as a pointer. In java they are called references. So when you pass a vector its like passing a pointer to a vector. Most objects have a clone() method, so that can be used to pass an actual copy if you should need to. This is similar to the copy constructor in C++.
I wonder, is there a way to avoid writing clone methods for your own home brewed classes by means of a generic method using some form of introspection for running down properties?
You're asking about pass-by-value versus pass-by-reference semantics. These links will answer your question.
Separate names with a comma.