我无法运行它,我不知道为什么? [英] i cant run it i dont know why?
本文介绍了我无法运行它,我不知道为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
package sum;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
int a;
int n ;
System.out.println("enter an integer :");
a = input.nextInt();
System.out.println("enter an integer :");
n= input.nextInt();
System.out.println(sum(a,n));
}
public static double sum(int n,double []a)
{
if(n ==0)
return n;
return sum(a,n-1)+a[n-1];
}
private static double sum(double[] a, int i) {
throw new UnsupportedOperationException("Not yet implemented");
}
}
程序在一行中有错误(System.out.println(sum(a,n));)??
非常抱歉,我不知道如何使用Main.sum(a,n)调用sum并将其写为业余爱好者
谢谢:玫瑰:
the programe have an error in the line (System.out.println(sum(a,n));)??
I really sorry i dont know how i must call sum using Main.sum(a, n) and write it i am amateur
thanks:rose:
推荐答案
您的课程中没有sum(int i1, int i2)
方法.
Did你读过我以前的答案吗?您有两个sum()
重载,但是您的调用与两个重载都不匹配,因此编译器将拒绝它.
Did you read my previous answer? You have two overloads of sum()
and yet your call does not match either of them, so the compiler will reject it.
mf_arian写道:
mf_arian wrote:
System.out.println(sum(a,n));
System.out.println(sum(a,n));
我认为最好使用
调用sum
Main.sum(a,n)
还要确保签名正确匹配.我可以看到签名是不同的.
;)
I think it is better to call sum using
Main.sum(a, n)
Also make sure the signature matches properly. I can see the signature is different.
;)
这篇关于我无法运行它,我不知道为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文