Difference between call by value and call by reference in Java

Submitted 3 years, 1 month ago
Ticket #363
Views 355
Language/Framework Java
Priority Low
Status Closed

Can I know the exact difference between them and when should we use them ....

Thanks in advance.....

Submitted on Feb 28, 21
add a comment

1 Answer

Verified

In Java, all argument values are passed to a method using only call by value (pass by value) mechanism.

There is no call by reference (pass by reference) mechanism in Java.

  “Call by value” in Java means that argument’s value is copied and is passed to the parameter list of a method.

That is, when we call a method with passing argument values to the parameter list, these argument values are copied into the small portion of memory and a copy of each value is passed to the parameters of the called method.

Submitted 3 years, 1 month ago


Latest Blogs