, .
MyObject obj1 = new MyObject();
obj2 = obj1;
Here, in this case, any changes you make to obj1 will be displayed in obj2 and vice versa, since obj2 contains the memory location obj1.
but if you do not want it, the change made in obj2 will be visible in obj1, or any change made in obj1 will be visible in obj2, then you will do Cloning. In this case, both objects will have different memory locations.
source
share