All:
I am confused by two questions that have surfaced in my mock exams. Read on for your entertainment pleasure and please assist this greenhorn
With this question I am taught that when an Object reference is passed to a method, the copy of the object reference is received as the method argument. The copy also refers to the original object itself. Since arrays are objects, the change made within the g()method to the int[]c argument (LINE 2)
affects the original array object (int[]c on LINE 1), so the value of the first element of the original version of the array changes to 1.
Fine. now....
Here I am told that on LINE 2, the method f() makes the local variable s refer to null(LINE 1), but that
this does not affect the original variable in the main function. 'Scuse me?? How can when something happens in a method to an array, which is an Object, also affect the original version of that array, but yet when a
String, which also is an object, gets manipulated by a method, the change is not reflected back on the orginal version?
Can someone please clarify?
Thanks to all for your time and response
g
[ May 16, 2007: Message edited by: G Marshall ]
[ May 16, 2007: Message edited by: G Marshall ]
EDIT by mw: Added
Code Tags.
[ May 16, 2007: Message edited by: marc weber ]
(quietened down shout in topic title - barry)
[ May 17, 2007: Message edited by: Barry Gaunt ]