Difference between static nested class and regular class

前端 未结 5 1127
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-11 07:52

I know this is a bit of a duplicate question but I want to ask it in a very specific way in order to clarify a very important point. The primary question being: Is there any

5条回答
  •  [愿得一人]
    2020-12-11 08:27

    Another subtle difference occurs in reflective use-cases. The class name you need to load a class with Class.forName is a bit funky.

    Class.forName("com.acme.OuterClass.Innerclass");  // not found
    Class.forName("com.acme.OuterClass$Innerclass");  // correct
    

    See also: Instantiate nested static class using Class.forName.

提交回复
热议问题