Pass By Value And Pass By Reference
| Pass By Value | Pass By Reference |
|---|---|
| It means passing a primitive variable into method. | It means passing an object reference to the method. |
| Pass by variable means Pass by copy of the variable. | When you pass an object variable into method, you must keep in mind that you're passing the object reference and not the actual object it self. |
| So for the primitive variable, you are always passing a copy of bits in the variable. | Passing the copy of reference variable to the method. In other words, both the caller and called method will now have identical copies of the exact( not a copy ) object on the heap. |
Note: It makes no difference if you're
passing primitive or reference variables, you are always passing a
copy of bits int he variable.


