Say we have an ArrayList myArray. I want to modify an object by calling its function. If I do it this way, will the original object be changed or not?
myArray.get(0).myModyfyingFunction();
To clarify further - I am concerned if get() actually returns a reference to my original object or does it only return a copy of my original object.
get()
will return a reference to the object, never a copy. Any modification you do on the returned reference will be made on the object itself