Using an inner class name and an object name same in Java

前端 未结 3 900
执念已碎
执念已碎 2021-02-13 23:31

In the following code snippet, presumably it appears that it should issue some compilation error but it doesn\'t:

class Outer {
    public static class Inner {
          


        
3条回答
  •  生来不讨喜
    2021-02-13 23:54

    Think of the inner class has actually have its own .java file. That will make it clear to you why it chooses the variable over the Inner class.

提交回复
热议问题