Using the lead - passing arrays and other collections in Java
Archive - Originally posted on "The Horse's Mouth" - 2015-02-16 19:29:44 - Graham EllisIf you're taking the dog for a walk, it's much more lightweight to simply take the lead and have the dog follow than to actually carry the dog. And if you're passing a whole collection of data into a function, it's much more lightweight to pass in the address or reference to the collection than to copy the collection in. And if you do that, you can make alterations from within the function and have those alterations be reflected in the orignal calling code, which is both powerful (if you thing about what youre doing) and dangerous (if you don't).
Source code of an example in Java - [here].