– notes, snippet codes, and my journal

“pass by value” and “pass by reference” In JAVA

leave a comment »

• What is the difference between “pass by value” and “pass by reference”? How are these ideas different in object-oriented systems and procedural systems?

Pass by value :
Pass by value mean it passing a copy of the value to be passed.
If a variable is passed, the variable receives the copy of the variable value. The value of the original variable can’t be changed within this method, because the variable which passed only has a copy of value from the original variable.

Pass by reference
Pass by reference mean it passing a reference of address in memory.
When it comes to object, it mean passing by references to an object.

Note for JAVA:
Java does manipulates object by reference, and all object variables are references.
However, java doesn’t pass method arguments by reference. It passes them by value.


Written by snippetjournal

September 29, 2012 at 2:00 pm

Posted in Programming

Tagged with , , ,

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: