I know what is shallow copy and deep copy, however I still don't understand what's the difference between creating a deep copy with clone method and creating new instance with same values of other instance. or creating static function in main that does this copy.
For example, let's say I have class A with integers x,y. and I created an instance called a1 and initialized it with x=1, y=2:
A a1 = new A(1,2);
What's the difference between a deep copy (using clone method) and doing one of the following?:
A a2 = new A(a1.x, a1.y);
A a3 = new A(a1);