![](/img/trans.png)
[英]Method(double, double) is not applicable for the arguments (double[], double[])
[英]how to solve The method add(double, double, int, double) in the type main is not applicable for the arguments (double, double, double, double)
如果您正在回复,请给我看代码和提示代码来自兄弟代码,我仍然在学习抱歉
我已经修复了其他几个错误,但它仍然不起作用
public class main {
public static void main(String[] args) {
double x = add(1.0,2.0,3.0,4.0);
System.out.println(x);
}
static int add (int a , int b) {
System.out.println("this is a overloaded method #1");
return a + b;
}
static int add (int a , int b, int c) {
System.out.println("this is a overloaded method #2");
return a + b + c;
}
static int add (int a , int b, int c, int d) {
System.out.println("this is a overloaded method #3");
return a + b + c + d;
}
static int add (double a , double b) {
System.out.println("this is a overloaded method #4");
return a + b;
}
static int add (double a ,double b, double c){
System.out.println("this is a overloaded method #5");
return a + b + c;
}
static int add (double a , double b, int c, double d) {
System.out.println("this is a overloaded method #6");
return a + b + c + d;
}
}
要修复错误,您需要做一些事情:
int
更新为double
(在单词static
之后的那个)int c
更新为double c
因此,您的方法 4、5 和 6 应如下所示:
static double add(double a, double b) {
System.out.println("this is a overloaded method #4");
return a + b;
}
static double add(double a, double b, double c){
System.out.println("this is a overloaded method #5");
return a + b + c;
}
static double add(double a, double b, double c, double d) {
System.out.println("this is a overloaded method #6");
return a + b + c + d;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.