Home Manipulating data structures

Using copy constructors

You may use the copy constructor for Sets and Maps. If you want to use the copy constructor for any other kind of data structure, you should ask permission first.

Manipulating strings

When attempting to manipulate or "modify" a String, you should try and design your code such that your code "builds up" a new String rather then trying to "modify" an existing String. In particular, you should remember that Strings are immutable (unchanging) so trying to "modify" a String is not something you can really do.

Do not leak internal state

You should never return a value in such a way that a client is able to use that data to modify a private field.

Or, to rephrase, you should never return a reference to a field referring to some mutable data structure.