When should I use private static inner classes?

Luigi Viggiano

You have to use them when you want to make a structure used inside your class as an utility (i.e. to group some variables together, or to have an utility class with static methods to be shown ONLY in that class, or to have a private store for configuration data that has to be kept private from the client).

Pay attention on that if it's static you have an unique instance of the inner Class object. If not static you have to instantiate the Outlevel object and after the inner class (you need an instance of the outer object to make the inner class' instance).

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact