The Department of Computer Science & Engineering
STUART C. SHAPIRO: CSE 116 B
Try adding something twice and removing it once. Is it there?
Note: BeanShell, but not compiler, allows HashSets of primitive values.
HashSets of chars and to
thisexcept for some small change.
For example Strings
are immutable sequences of
are mutable sequences of
concat(String str) to
append(String str), by trying
in the BeanShell
s1 = new String("Original"); sb1 = new StringBuffer("Original"); s2 = s1; sb2 = sb1; s1 = s1.concat(" and modified"); sb1 = sb1.append(" and modified"); print(s2); print(sb2);
Mutators need not return
this, but if they do, they
can be composed (see text, page 68).
Mutable objects avoid creating extra objects.
Mutators may cause a variable to "change", even though it has not been referenced. (See