2.7 Class Variables
Introduction
A class variable (declared with `static`) belongs to the class itself rather than to any single object — there is exactly one copy, shared by every instance. Class variables are useful for values that should be consistent across all objects, like a running count of how many objects have been created.
Key Concepts
Java Syntax
Code Examples
Every time a `Student` is constructed, the shared `totalCount` field increments. Because it's `static`, both objects update the same single counter.