• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Pass by value

 
Skanda Raman
Ranch Hand
Posts: 205
Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In the below url of javaranch

http://www.javaranch.com/campfire/StoryPassBy.jsp
And in the below section

How does pass-by-value work with references?
Way too many people say "Java passes primitive by value and objects by reference". This is not the way it should be stated. Java passes everything by value. With primitives, you get a copy of the contents. With references you get a copy of the contents.


Please see the highlighted section,

should that mean "With reference you get a copy of the reference"

Please let me know if i am wrong.

 
Campbell Ritchie
Sheriff
Posts: 48652
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What it means is that you get a copy of the contents of the memory location.

If you have a few hours to spare, have a look at this thread from July.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic