请问我的代码哪里错了?
public class test {
int[] acount(int m, int n){
int x,y,z;
int i = 0;
int result[] = new int[9];
for (x = 0; x < 9; x++)
{for (y = 0 ; y < 9 ;y++){
for (z = 0; z < 9; z++){
if (x + y == m){
if (y + z == n){
result[i] = x;
i ++;
}
}
}
}
}
return result;
}
public static void main(int[] args){
int output[];
test test1 = new test();
output = test1.acount(args[0],args[1]);
for (int a = 0; a < output.length; a++){
System.out.println(output[a]);
}
}
}
执行的时候报Exception in thread "main" java.lang.NoSuchMethodError: main
问题点数:20、回复次数:10Top
1 楼believefym(feng)回复于 2005-08-01 11:37:05 得分 0
这种问题很有可能是classpath的问题,在前面加.;试试看Top
2 楼hyunique()回复于 2005-08-01 11:46:31 得分 0
不是classpath的问题,在前面已经加了.; 。其实的程序也可以执行的。Top
3 楼believefym(feng)回复于 2005-08-01 11:50:08 得分 0
发现你的main函数的参数错了,应该是String args[],其他参数程序当一般函数,而不是程序的入口了Top
4 楼qyflaoda(戒骄戒躁)回复于 2005-08-01 11:50:16 得分 5
public static void main(int[] args) ???
public static void main(String[] args) 才对阿
Top
5 楼ziyeqiufeng(子夜秋风)回复于 2005-08-01 12:02:32 得分 5
public static void main(int[] args)定义不对
应该这样定义
public static void main(String[] args)
或着
public static void main(String args[])Top
6 楼homesos(熊猫贩子)回复于 2005-08-01 12:28:39 得分 0
入口方法main的参数必须是String类型的数组Top
7 楼lei198203(lei)回复于 2005-08-01 13:01:54 得分 10
public static void main(int[] args)改成 public static void main(String[] args)
然后
output = test1.acount(args[0],args[1]); 改成
output = test1.acount(Integer.parseInt(args[0]), Integer.parseInt(args[1]));
Top
8 楼hyunique()回复于 2005-08-01 13:01:57 得分 0
把String类型参数转换成int类型怎么转换Top
9 楼qyflaoda(戒骄戒躁)回复于 2005-08-01 13:11:14 得分 0
Integer.parseInt(String)Top
10 楼hyunique()回复于 2005-08-01 13:27:03 得分 0
已经OK了。Top




