Inner classes with the same name as an outer class?

前端 未结 5 1077
无人共我
无人共我 2020-12-17 17:44

Constraints:

I have a maven source code generator that I wrote that is creating POJO classes from some data files that have nested namespaces. I w

5条回答
  •  伪装坚强ぢ
    2020-12-17 18:27

    Depending on what you're after, the following might work for you:

    public class A {
      class B extends C {
      }
    
      public static void main(String[] args) {
        new A().new B().new A();
      }
    }
    
    class C {
      class A {
        {
          System.out.println(getClass());
        }
      }
    }
    

提交回复
热议问题