Java : recursive constructor call and stackoverflow error

后端 未结 5 1970
醉话见心
醉话见心 2020-12-03 20:00

Please help to understand why does the following code

public class HeapQn1 {

    /**
     * @param args
     */
    public HeapQn1() {
        new HeapQn1(         


        
5条回答
  •  长情又很酷
    2020-12-03 20:40

    You are right: the stack is much smaller than the heap, and no object will be fully created.

提交回复
热议问题