A static field is associated with the class, so one field value is shared by every object of that class. Accidentally using static where an instance field is intended can leak one object's data into another object's context without raising an exception. section 3.11 section 3.12
Accidental sharing
In the Person example, private static String name means that setName on one Person changes what getName returns for every Person. The defect may remain hidden when objects are created and discarded sequentially, but simultaneous users can receive one another's data. section 3.11
Check static fields before accepting the apparent simplicity of a passing test:
- Use an instance field when each object needs independent state; reserve nonfinal static fields for limited, deliberate uses. section 3.11
- Do not assume final removes sharing: a static final mutable collection can still hold data shared by every object. section 3.11
- Test concurrent and overlapping object use, not only sequential use, because shared state can pass simple tests and fail as usage grows. section 3.11
- Review IDE highlighting and enable relevant inspections: IntelliJ IDEA reports assignments to static fields from instance contexts, while SonarLint reports S2696 by default. section 3.11






