Java : Class inheriting self

后端 未结 8 1313
刺人心
刺人心 2021-02-15 11:19

I know this is pointless: I just find it funny and I want to inquire more about the mechanics of what happens when you create a class that inherits itself, resulting in a stack

8条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-02-15 11:42

    You can get the answer by:

    Class.forName("MyClass");
    

    This way it gets resolved but not instantiated. So you can chack if resolution itself causes the crash.

    I guess it depends on the JVM you use.

提交回复
热议问题