Recursive constructor invocation error can't find solution

后端 未结 2 1124
后悔当初
后悔当初 2021-01-29 11:49

I get the recursive construct overflow invocation error at the four public tuna parts (parts=maybe a class or something else?). It worked on the tutorial but not for me and can\

2条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2021-01-29 12:25

    You're doing a recursive call here:

    public tuna(int h, int m, int s){
        this(h,m,s);    //with hours, minutes and seconds
    }
    

    You should set your private members in this constructor. It should be something like:

    public tuna(int h, int m, int s){
        this.h = h;    //with hours, minutes and seconds
        this.m = m;
        this.s = s;
    }
    

提交回复
热议问题