5. Passing a Copied Value in and out of methods.

Listing 5. Passing a Copied Value in and out of methods.


class Order
{
    ...
    public void setDeliveryDate(Date newDeliveryDate)
        { deliveryDate = (Date) newDeliveryDate.clone(); }
    public Date getDeliveryDate()
        { return (Date) deliveryDate.clone(); }
    private Date deliveryDate;
}

About the Author

Kevlin Henney is a Principal Technologist with QA Training in the UK.