If the object is having any pointer then deep copy is preferred because in case of shallow copy, if pointer is changed or object is destroyed then dangling pointer problem may arise.
Wonderful post on pass by reference and pass by value confusion of Java
http://www.javaworld.com/javaworld/javaqa/2000-05/03-qa-0526-pass.html
Values of reference is passed by address and reference itself is passed by value.
No comments:
Post a Comment