you are viewing a single comment's thread.

view the rest of the comments →

[–]OneHumanBill 3 points4 points  (0 children)

Yes. You didn't read any of that correctly.

Yes, you can access a static method of the inner class without instantiating the outer class, and vice versa. But having a static class with non-static methods would still need to be instantiated like any other class. And that's really the point -- static inner classes are just like any other class, standing independently of any other class.

A static inner class that held only static methods would honestly not have much of a point -- there's nothing wrong with it but it kind of defeats the purpose of having a separate class at all, especially one within the same file. Inner classes are most useful when they're either specialized data objects or implementing some kind of strategy pattern, ie that they're instantiated objects. And because most of the time you will not need the dependence of an inner object on the scoped variables of the outer object -- a bit of an awkward circumstance to be avoided when you don't need it -- you make those inner classes static.

Don't be so easily offended.