![](/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.