Wednesday, August 10, 2011

Difference in passing Array and Integer to a method in java?

In case of the integer, a copy of myInteger is used in the method, whereas passing an array, a copy of a reference to the object is used in the method. Therefore, since the reference (memories address) is pointing to the same reference/address, the array changes.

0 comments:

Post a Comment