O'Reilly logo
  • Gaurav Garg thinks this is interesting:

A common use of private static member classes is to represent components of the object represented by their enclosing class. For example, consider a Map instance, which associates keys with values. Many Map implementations have an internal Entry object for each key-value pair in the map. While each entry is associated with a map, the methods on an entry (getKey, getValue, and setValue) do not need access to the map. Therefore, it would be wasteful to use a nonstatic member class to represent entries: a private static member class is best. If you accidentally omit the static modifier in the entry declaration, the map will still work, but each ent...


Cover of Effective Java, 3rd Edition


In case of static - private static class would not have reference to static class like other static members static class would also belong to the class not any specific object of enclosing class so we instance of inner class are independent of enclosing class instance.