DEV Community

Effective Java! Favor Static Members Classes over Non-Static

Kyle Carter on May 13, 2020

Java provides four ways to declare a class within another class: static member class, nonstatic member classes, anonymous classes, and local classe...
Collapse
 
moaxcp profile image
John Mercier

I think another feature of static class is that private members are visible to the outer class. This allows for some convenient uses of a static inner classes. In the case of Builders there is no need to provide getters for the members of the Builder. The constructor of the outer class can access the private member varaibles directly.