File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed
Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -398,3 +398,29 @@ class BigOuter {
398398The class itself isn't really "` static ` ", there's no such thing as a ` static ` class. The ` static ` modifier in this case says
399399that the nested class is a ` static ` member of the outer class. That means it can be accessed, as with other ` static `
400400members, without having an instance of the outer class.
401+
402+ {% highlight java linenos %}
403+ class Outer {
404+ static class Nest {
405+ void go() {
406+ System.out.println("hi outer");
407+ }
408+ }
409+ }
410+
411+ class Inner {
412+ static class Nest {
413+ void go() {
414+ System.out.println("hi inner");
415+ }
416+ }
417+
418+ public static void main(String[] args) {
419+ Outer.Nest outerNest = new Outer.Nest(); // access static inner class
420+ outerNest.go(); // present inside a different class
421+
422+ Nest innerNest = new Nest(); // access static inner class
423+ innerNest.go(); // present inside the same class
424+ }
425+ }
426+ {% endhighlight %}
You can’t perform that action at this time.
0 commit comments