Thursday, June 5, 2008

Is Java Pass by value or pass by reference

Congratulations .... you are the 99,99,999 person to ask that ... click "here" to clain your prize.... ;-)
Let me see .. whats the correct ans....
Some of you may say its "pass by value for primitive data types and pass by reference for objects" ... hmmmm wrong ... actually the intellignet lot ( at least the booky's ) would say "java is pass by value for primitive types and passes refernce by value for objects.. so java is pass by value"... correct buddy ..... you the man !!

BUT ... thats incomplete my friend ... complete answer is .... java is pass by value for primitive types , passes reference by value for object types ... and when passing objects to remote method (ie RMI) its pass by object copy NOT reference copy.

No comments: