This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
hi! Actually i was a bit confused regarding the approach that java follows regarding passing objects as parameters....is it by value or by reference?? I am preperaing for SCJP1.4 and could'nt find a reasonable explanation so far. Would be obliged if u could give a detailed explanation. Thanx! regards.. Shambhavi.
Java passes all parameters by value -- but to understand this fully, you have to remember that all objects are referenced via pointers, and it's the pointers, not the objects themselves, that are passed by value when a parameter is an object type.
For a more detailed explanation with examples, please read this and then this.
to clear ur doubt in a shortcut ...remember this ...."in , java, all parameters are passed by value, that is, an actual parameter is eveluated and its value is assigned to the corresponding formal parameter . in a tabular format it would be as below
when its a Primitive data types(int, byte, etc) then its Primitive data value(value ..note that)
when its a Class type then its a reference value
when its a
array type then its a reference value [ September 16, 2004: Message edited by: prashant bhogvan ]
Impossible is I M Possible
Joined: Sep 15, 2004
u said u were preparing for certification .... if u r refering the book "khalid mughal and rass....." ...then looking at the diagrams at pages between 86-93 ...willl clear all your doubts in this matter