Actually when you assign a new array object to the i in the change i method you create two different arrays.
Try this code
This will explain it better.
Edited :To give code example
[Bsc in Computer Science and Engineering] [SCJP 80%][BCS certificate level]
Joined: Aug 08, 2009
Keep that in my mind java always use pass by value.But in object passing the idea may be little bit ambiguous.Because what you pass is the bit pattern of the reference variable . So when you pass the bit pattern ,the reference in the method will point to the same object .So if you update one other will get changed.But if you try to say something like i=new int; then you create a completely different object.
'i' reference variable in main method points to an array object containing an elemnt '1'....
when this is passed to change_i method then there is another reference var. 'i' in that method(change_i method) pointing to the same object on the heap.....
So, that means two array reference variables are of the same name 'i' pointing to the same object,,,,?
And this is happening because both these variables are declared in different methods, so there is no name collision or ambiguity in names?