Java Reference
In-Depth Information
The output is shown here:
Often, as this example shows, an advantage of providing a constructor that uses one object
to initialize another is efficiency. In this case, when
s2
is constructed, it is not necessary to
recompute the summation. Of course, even in cases when efficiency is not an issue, it is
often useful to provide a constructor that makes a copy of an object.