Link Details

Link 935207 thumbnail
User 1073519 avatar

By lokeshgupta1981
via architects.dzone.com
Published: Mar 08 2013 / 17:44

There has been a good amount of debate on whether "Java is pass by value or pass by reference?". Well, lets conclude it last time, Java is pass by value and not pass by reference. If it had been pass by reference, we should have been able to C like swaping of objects, but we can't do that in java. We know it already, right? When you pass a instance to a method, its memory address are copied bit by bit to new reference variable, thus both pointing to same instance. But if you change the reference inside method, original reference will not get chnage. If it was pass by reference, then it would have got changed also.
  • 13
  • 7
  • 1335
  • 1444

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Java Performance Optimization
Written by: Pierre-Hugues Charbonneau
Featured Refcardz: Top Refcardz:
  1. Design Patterns
  2. OO JS
  3. Cont. Delivery
  4. Java EE7
  5. HTML5 Mobile
  1. Node.js
  2. Debugging JavaScript
  3. OO JS
  4. JSON
  5. Ajax