Topic: 为什么我的代码出现如下错误啊?请帮忙!!

  Print this page

1.为什么我的代码出现如下错误啊?请帮忙!! Copy to clipboard
Posted by: fxbianxiu
Posted on: 2005-01-19 20:52

class box{
int suma;
int sum(int a,int b,int c ){
suma=a+b+c;
return suma;
}
}

class demo{
public static void main(String argc[] )
{
System.out.println("Please input : ");
box box1=new box();
System.out.println("out:"+box1.sum(10,20,30));

}
}





我写的以上代码为什么在 NetBeans 出现如下错误呢?让我百思不得解,请高手帮忙!



class box{
int suma;
int sum(int a,int b,int c ){
suma=a+b+c;
return suma;
}
}

class demo{
public static void main(String argc[] )
{
System.out.println("Please input : ");
box box1=new box();
System.out.println("out:"+box1.sum(10,20,30));

}
}

2.Re:为什么我的代码出现如下错误啊?请帮忙!! [Re: fxbianxiu] Copy to clipboard
Posted by: fxbianxiu
Posted on: 2005-01-19 20:55

java.lang.NoSuchMethodError: box.sum(III)I
at demo.main(demo.java:17)
Exception in thread "main"

是出现这样的错误!

3.Re:为什么我的代码出现如下错误啊?请帮忙!! [Re: fxbianxiu] Copy to clipboard
Posted by: lover
Posted on: 2005-01-20 09:51

没错.
把class demo改为public class demo


   Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent
Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1
客服电话 18559299278    客服信箱 714923@qq.com    客服QQ 714923