#46 – There Is Only One Copy of Static Data

With instance data members of a class, there is a unique set of data that exists for each instance of the class that you create.  However, for static data members, there is always just one copy of the static data for that class.  Since the data is associated with no particular instance of the class, all references to that static data work with the same copy.

 // Create two new Person objects--two sets of instance data.
 Person p1 = new Person("Sean", 46);
 Person p2 = new Person("Fred", 28);

 // Change static data--one copy for entire Person class
 Person.Motto = "It's good to be human";