Link to home
Start Free TrialLog in
Avatar of chenwei
chenwei

asked on

How to clone an object complettly?

Assumed I have a class which contains elements of other classes as follow:

public ClassB{
...
}

public ClassA{
...
  private String str1;
  private B b;
...
}

I can clone the A as follow:
...
  A a = new A();
  A c = a.clone();

But this will just clone the member str1.  How can I clone the A complettly?
ASKER CERTIFIED SOLUTION
Avatar of Tomas Helgi Johannsson
Tomas Helgi Johannsson
Flag of Iceland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial