Because you're sending an array of integers (which isn't getting changed - the reference is the same when the method returns.) But you can change the array's elements within the method - just as you can change the state of an object whose reference has been passed to a method.
Hi Mindy, First, I strongly suggest you read the Campfire Story Pass-By-Value. It gives a very good explanation of how java deals with passing by value and reference. The first declaration of i is not used since you declare it again inside the main method and then pass it to change_i(). As a matter of fact you would have to make the declaration of the first i static before you could access the array since it is outside any method or static blocks. When you passed i to the change_i method you passed the reference to i. Now any changes made to i's elements are made to the original version of i. In other words a copy of i was not sent to change_i. A reference was sent giving change_i() direct access to the original copy of i and all its elements. Hope this helps
posted 19 years ago
Thank you Richard, after reading your explaination and the campfire "pass by value", I totally understand now.
Thanks again! Mindy [This message has been edited by Mindy Wu (edited June 12, 2001).]
There are 29 Knuts in one Sickle, and 17 Sickles make up a Galleon. 42 tiny ads in a knut:
Devious Experiments for a Truly Passive Greenhouse!