Java : Class inheriting self

后端 未结 8 2011
悲&欢浪女
悲&欢浪女 2021-02-15 11:21

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:38

    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.

提交回复
热议问题