【发布时间】:2016-07-28 14:06:30
【问题描述】:
我正在尝试制作一个取三个数字的平均值的简单程序,但我收到一条错误消息,提示
"类中的构造函数平均值不能应用于给定类型; 必需:无参数 找到:int,int,int"
这是我的代码:
public class ave {
public static void main(String args[]) {
average object = new average(3,4,6);
}
}
这是我的构造函数代码
public class average {
public double takeaverage(double first, double second, double third) {
double ave = (first + second + third)/3;
System.out.println(ave);
return ave; }
}
【问题讨论】:
-
object.takeaverage(3,4,6);这是一种方法 -
确保对类名使用 Pascal 大小写(即 Average、AverageClass、ThisIsAReallyLongNameForAClassThatAveragesThreeNumbers)
标签: java constructor arguments