Name Binding - Rebinding and Mutation

Rebinding and Mutation

Rebinding should not be confused with mutation — "rebinding" is a change to the referencing identifier; "mutation" is a change to the referenced value. Consider the following Java code:

LinkedList list; list = new LinkedList; list.add("foo"); list = null;

The identifier list initially references nothing (it is uninitialized); it is then rebound to reference an object (a linked list of strings). The linked list referenced by list is then mutated, adding a string to the list. Lastly, list is rebound to null.

Read more about this topic:  Name Binding