Instance and Static Members
Each member of a class can be classified in one of two ways: instance member or static member. When a copy of a class is created, it is considered instantiated. At that point in time, that class exists as a sole entity, with its own set of attributes and behavior. If a second instance of that class were created, it would have a separate set of data from that of the first class instance. This continues ad infinitum for as long as new instances are created. This is the normal course of action for classes, unless one or more class members are labeled as static.
By using the static key word with a class member, only a single copy of that member can exist at any given time, regardless of how many copies of a class are instantiated. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access