Ankit Garg wrote:Static inner classes can have static members, non-static inner classes can't.
IMO, using a characteristic difference between regular inner classes and static inner (nested) classes, to prove whether anonymous inner classes are "static" or not, is very debatable. Anonymous inner classes are so different from regular inner/nested classes that I can easily make an argument that concludes differently.
For example, non-static inner classes needs an instance of an outer class to be instantiated. And in the cases of instances of anonymous inner classes that are instantiated during static initialization, or within static methods, there are no instances in context that be used as the instance of the outer class.
Paul Anilprem wrote:As per JLS section 15.9.5:
An anonymous class is always an inner class; it is never static.
Agreed. There is no defined behavior for "static" with anonymous inner classes. It is what it is -- and it is different from regular inner/nested classes.
Henry