
46
Chapter 4: Classes and Objects []
this.balance = balance;
The value of fredsAccount, accountNo after invoking the constructor
Account fredsAccount = new Account(123, "Fred", 60);
is 12 3 as expected.
this is actually a reference to the object being constructed. All object variables are
references, so the following code fragment:
Account fredsAccount = new Account(...);
Account billsAccount = fredsAccount;
billsAccount.balance = 500;
sets the balance for both Bill and Fred.
4.9 StringBuffer
A StringBuffer object is similar to a String object but is more efficient when you are repeatedly
appending characters ...