Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Some objects appear to be immutable because they have no mutator methods. For example, the java.lang.CharacterSequence interface describes an immutable sequence of characters. It should be noted that if the underlying implementation on which the CharacterSequence is based changes, the value of the CharacterSequence also changes. Such objects must be defensively copied before use. It is also permissible to use the toString() method to make them immutable before passing them as parameters. Mutable fields should not be stored in static variables. When this is not possiblethere is no other alternative, create defensive copies of the fields to avoid exposing them to untrusted code.

...