
8.5 Using Arrays in Classes 503
Figure 8.19
Output from the
CellPhoneClient Class
A call to the equals method to compare c2 and c3 (lines 37–41) returns a
value of true, because the two objects have the same data.
Finally, we test encapsulation two ways. First, we change a value in the bills
array, then print c2 again to verify that its data has not changed (lines 43–48).
Second, we call the accessor method for the cellBills array and change a value
in the array returned from the method call. We again print c2 to verify that its
data is unchanged (lines 50–57). Testing the CellPhone class with such an
example is helpful in checking that we have correctly ...