News

The implementation technique outlined above is much like the one used by String and StringBuffer companion classes in the standard Java implementation, except that the mutable StringBuffer is not ...
For that to be possible, either you had to cast from mutable to immutable (which you shouldn't have) or the mutable string derives from the immutable string (which it shouldn't have).
You might know that Java passes by value, but it helps to understand why. Here's what happens when you pass mutable and immutable object references in Java.