Java - pass by value or pass by Reference
One of the biggest confusion in Java programming language is whether
java is Pass by Value or Pass by Reference. I ask this question a lot in
interviews and still see interviewee confused with it. So I thought to
write a post about it to clarify all the confusions around it.
Pass by Value: The method parameter values are copied to
another variable and then the copied object is passed, that’s why it’s
called pass by value.
Pass by Reference: An alias or reference to the actual parameter is passed to the method, that’s why it’s called pass by reference.
Comments
Post a Comment