The clone() method creates a new array with its own memory but contains references to the same objects for non-primitive data types.
Q. Meaning the array is new but the elements in the array point to the same location as that of the original?? so if i access an element and mutate the element the element in the original array also gets affected?
That is accurate—this behavior is known as a shallow copy.
When you clone an array of objects in Java:
Mutating the object's internal state affects both arrays because both array slots point to the exact same object in memory.
Reassigning the reference at an array index affects only that array, because the array containers themselves are separate objects.
Q. so we can add new elements without the other knowing that's the main usecase of the clone
Yes, that is a primary use case—isolating the array structure and references so one array can be modified, reordered, or reassigned without affecting the other. This pattern is commonly known as defensive copying