• Post Reply Bookmark Topic Watch Topic
  • New Topic

Pass by ref and value  RSS feed

 
aakash bhatt
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do we acheive parameter passing by reference and pass by value in Java
 
Ernest Friedman-Hill
author and iconoclast
Sheriff
Posts: 24217
38
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In a nutshell: all parameters in Java are passed by value. Because variables of object type are actually references to objects, these references themselves are passed by value.
There's no way to pass a primitive type by reference, or an object by value.
See the JavaRanch "Campfire Stories," particularly the Pass by Value story, for more details.
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!