标题:[求助]这个重载程序好像没错,但提示错误
只看楼主
117ai
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-12-9
 问题点数:0 回复次数:5 
[求助]这个重载程序好像没错,但提示错误

class Try{
int x;
int y;
Try(int m){
x=m;
y=m;
}
Try(int m,int n){
x=m;
y=n;
}
int compute(){
return x+y;
}
int comput(int mul){
return (x+y)*mul;
}
}

class 重载{
public static void main(String args[]){
Try tryone;
Try trytwo;
tryone=new Try(5);
trytwo=new Try(10,10);
System.out.println(tryone.compute());
System.out.println(tryone.compute(3));
System.out.println(trytwo.compute());
System.out.println(trytwo.compute(3));
}
}
这个重载程序好像没错,但提示错误,我不明白为什么错

搜索更多相关主题的帖子: 提示 重载 
2006-12-17 21:30
shenba
Rank: 1
等 级:新手上路
威 望:1
帖 子:179
专家分:0
注 册:2006-9-17
得分:0 
int comput(int mul){
return (x+y)*mul;
}

这里是comput 不是compute

2006-12-17 22:58
千里冰封
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:灌水之王
等 级:版主
威 望:155
帖 子:28477
专家分:59
注 册:2006-2-26
得分:0 
int compute(int mul){
return (x+y)*mul;
}


你的程序小了一个e

可惜不是你,陪我到最后
2006-12-17 22:59
117ai
Rank: 1
等 级:新手上路
帖 子:200
专家分:0
注 册:2006-12-9
得分:0 
哦,这个是我没没清楚,不好思意,但不是那里错也运行不了`它说:java.lang.NoSuchMethodError:main
Exception in thread"main"
这就很难理解了~!

人真的很奇怪,以前看书时老喜欢看表,希望时间快点过;现在看书总是不敢看表,但时间却很快过!
2006-12-17 23:40
禹_二
Rank: 1
等 级:新手上路
帖 子:661
专家分:0
注 册:2006-9-13
得分:0 

肯定是你的文件名和第一个类一样了!!


2006-12-17 23:46
yqfang310
Rank: 2
等 级:新手上路
威 望:4
帖 子:458
专家分:0
注 册:2006-10-10
得分:0 
没事啊,改了int comput(int mul)不就可以了

JAVA是什么?我也不清楚......
2006-12-18 00:00



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-110169-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 2.327999 second(s), 9 queries.
Copyright©2004-2025, BCCN.NET, All Rights Reserved