gpt4 book ai didi

java - 错误打印: “actual and formal argument lists differ in length java”

转载 作者:行者123 更新时间:2023-12-02 11:15:21 26 4
gpt4 key购买 nike

我对println有问题。我试图将“方法”从一个类打印到另一个类,但出现此错误:

actual and formal argument lists differ in length java



这是方法:
public double dayInWeek(int day, int month, int year) {
int Day;
int M;
int Y = _year%100;
int C = _year/100;
int D = _day;
if (_month == 1) {
M = 13;
} else if ( _month == 2) {
M = 14;
} else {
M = _month;
}
return Day = (D + (26*(M+1))/10 + Y + Y/4 + C/4 - 2*C) % 7;
}

这主要是:
System.out.println(d5+" occurs on : "+d5.dayInWeek());

为什么会出现此错误?

最佳答案

我无法确定d5类型是什么,但是如果dayInWeek()是d5类中的方法,那么您应该执行以下操作:

public double dayInWeek(int day , int month ,int year){
return Day = (this.day + (26*(this.month+1))/10 + tis.year + this.year/4 + this.century/4 - 2*this.century) % 7;
}

或类似的东西。

另一方面,如果dayInWeek()是本地方法或静态方法,请执行以下操作:
System.out.println(d5+" occurs on : "+dayInWeek(d5.day, d5.month, d5.year));

或同样。就像错误所说的一样,dayInWeek得到的参数列表(无一个)与dayInWeek想要的参数列表(3个整数)不同

关于java - 错误打印: “actual and formal argument lists differ in length java” ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40872295/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com