This means that the arr variable in your initArray method will refer to the same array that you pass to it in your main method, but it is a different variable from the arr variable in your main method.
You essentially pass the value null to it, then you assign a new array to arr in initArray, which is a different variable from arr in your main method, so nothing happens to your main method variable.
What I wanted to do is to pass the null reference as an argument and let the other function assign a new array which will be used by the calling function.
As Java is pass by reference I was thinking that the reference is being passed and the same reference is used to assign a new Object if int array.
Himanshu Gupta wrote:As Java is pass by reference I was thinking that the reference is being passed and the same reference is used to assign a new Object if int array.
Why is that relevant? I'm not sure of the point you're trying to make.
Remember Java passes references by value.
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
4
posted
0
Agree it is by no means clear what you meant by that diagram. But I think you are mistaken there, if you think you can replace the null from a method call.