Arrays are objects in Java. Variables in Java actually store references to the object, instead of the real object.
When we pass an object reference to a method, we are changing the object that is in the heap of the memory.