Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Java - pass by value and pass by reference

 
marlajee Borstone
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends, I find this site as great site to increase knowledge. Thanks to JavaRanch !!

As I am stuck today as I could read somewhere Java supports only Pass-by-value and not pass-by-reference.

Can someone prove it that Java does not support Pass-by-Reference. I want to see some java beginner level code example for proof.

regards,
Dhaansumall
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


This question gets asked a lot. Take a look at this and this recent threads on the subject. You can also search the beginner forum for pass by value and find a number of discussions on the subject.
 
Mark Vedder
Ranch Hand
Posts: 624
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can also take a look at the Pass By Value campfire story (a fun name for a lesson) here at JavaRanch. It does a nice job of explaining the concept, and has some examples. Things get a little more confusing when dealing with objects and references to objects. The campfire story can help clear things up.
[ July 26, 2008: Message edited by: Mark Vedder ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic