Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
Ad icon
Colombo
Hard Disk For Sale
mazza
Updated:
Yesterday at 10:23 PM
land for sale
justasking
Updated:
Yesterday at 9:32 AM
AMD AM 5 Ryzen setup
prabodhamadusanka
Updated:
Thursday at 12:56 PM
Gampaha
ACER OKW223 Wired RGB Keyboard
chint
Updated:
Thursday at 10:17 AM
Gampaha
FANTECH R1 V2 RACING WHEEL
chint
Updated:
Thursday at 10:08 AM
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
programming පට්ටටම දන්නා අය එන්න
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="amilabanuka" data-source="post: 16781813" data-attributes="member: 5836"><p>Yes. it is not the pass by reference in C/C++, that is a different thing. In java objects are passed using references and the references is passed by value. So yes Java is Pass-by-value language. but when passing an object the value of the object reference is passed. so both sender and receiver points to the same object in the memory. If the object is pass-by-value then the receiving party should have their own copy of the object. that is not the case with java. this is bit tricky.</p><p></p><p>the pointer value of the object which lives in the heap is given to another variable. so both original variable and the new variable which got the pointer holds the reference (pointer to the memory in the heap). the object reference is passed by value. so the reference to an object which lives in the heap is passed to the method by passing the memory address of the object. </p><p></p><p>So when considering how the receiving party got hold of the object. it receives the object via getting the location of the object as a value in the parameter. Java cannot pass the actual object (as in C/C++) as it only supports passing values. but eventually the the receiving party gets a reference (which was passed as a value) to the object (not the object itself).</p><p></p><p></p><p>edit: <a href="http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value" target="_blank">http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value</a> has some good explanation.</p></blockquote><p></p>
[QUOTE="amilabanuka, post: 16781813, member: 5836"] Yes. it is not the pass by reference in C/C++, that is a different thing. In java objects are passed using references and the references is passed by value. So yes Java is Pass-by-value language. but when passing an object the value of the object reference is passed. so both sender and receiver points to the same object in the memory. If the object is pass-by-value then the receiving party should have their own copy of the object. that is not the case with java. this is bit tricky. the pointer value of the object which lives in the heap is given to another variable. so both original variable and the new variable which got the pointer holds the reference (pointer to the memory in the heap). the object reference is passed by value. so the reference to an object which lives in the heap is passed to the method by passing the memory address of the object. So when considering how the receiving party got hold of the object. it receives the object via getting the location of the object as a value in the parameter. Java cannot pass the actual object (as in C/C++) as it only supports passing values. but eventually the the receiving party gets a reference (which was passed as a value) to the object (not the object itself). edit: [URL="http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value"]http://stackoverflow.com/questions/40480/is-java-pass-by-reference-or-pass-by-value[/URL] has some good explanation. [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom