File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed
Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -377,4 +377,24 @@ The `doStuff(Foo f)` in `Bar` class takes an object of a class that implements `
377377anonymous class which is an implementation of the ` Foo ` interface as an argument to the ` doStuff() ` method (in line 4).
378378This we call it as __ Argument Defined Anonymous Class__ .
379379
380+ Please note that argument defined anonymous class end like ` }); ` but normal anonymous class end like ` }; ` .
380381
382+ ## Static Nested Class
383+
384+ Static Nested Classes are sometimes referred to as static inner classes, but they really aren't inner classes at all
385+ based on the standard definition of an inner class. While an inner class (regardless of the flavor) enjoys that special
386+ relationship with the outer class (or rather, the instances of the two classes share a relationship), a static nested
387+ class does not. It is simply __ a non-inner (also called "top-level") class scoped within another__ .
388+
389+ So with static classes, it's really more about name-space resolution than about an implicit relationship between the
390+ two classes. A static nested class is __ simply a class that's a static member of the enclosing class__ :
391+
392+ {% highlight java %}
393+ class BigOuter {
394+ static class Nested { }
395+ }
396+ {% endhighlight %}
397+
398+ The class itself isn't really ` static ` ; there's no such thing as a ` static ` class. The ` static ` modifier in this case says
399+ that the nested class is a ` static ` member of the outer class. That means it can be accessed, as with other ` static `
400+ members, without having an instance of the outer class.
You can’t perform that action at this time.
0 commit comments