Call by Value

We know that in Java everything is pass by value. But the interesting thing is that in case of Objects, the reference of the Object is pass by value.

Lesson learned while testing previous method for reversing link list.

If I call the method just like


All I get in n1 is 1.

So correct way to make the call is

n1= reverseLinkedList(n1);