递归构造函数调用错误找不到解决方案 [英] Recursive constructor invocation error can't find solution

查看:277
本文介绍了递归构造函数调用错误找不到解决方案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我得到递归构造溢出调用错误在四个公共金枪鱼部分(parts =也许一个类或其他?)。它工作的教程,但不是我,不能看到

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't seem to see where

public class tuna {
    private int hour;
    private int minute;
    private int second;

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


推荐答案

p>您正在这里执行递归调用:

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;
}

这篇关于递归构造函数调用错误找不到解决方案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆