New object of class inside the class

后端 未结 2 1852
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 15:20

In Java, or other OOP languages-

class MyClass{
  int a=5;
  MyClass b=new MyClass();

  void mymeth()
  {
  }
}

Here, creating an object of th

相关标签:
2条回答
  • 2021-01-29 16:07

    Yes.

    You run into a StackOverflowError (ironic, isn't it?) if you try to do that.

    0 讨论(0)
  • 2021-01-29 16:17

    It will lead to Stack Overflow Error.

    0 讨论(0)
提交回复
热议问题