 |
 |
 |
 |
 |
 |
|
|
Copy Constructor: Different…
|
|
|
|
|
 |
 |
 |
| • |
A
copy constructor is a constructor that creates a deep copy of an
|
|
|
object
that can be used for other purposes, such as creating a new
|
|
|
instance
of an immutable object from an old one
|
|
|
|
|
|
 |
 |
 |
 |
public
SavingsAccount(SavingsAccount oldAcct,
|
|
|
String
changeOfAddress)
|
|
{
|
|
. . . // create deep copy of oldAcct
|
|
}
|
|
|
// call
|
|
account
= new Savings Account(oldAcct, newAddress);
|
|
|
|