大神,我的代码哪里错了·?求指教,本人是新手

//filename:App9_4.java
public class App9_4
{
public static double multi(int n)
{
if(n<0)
throw new IllegalArgumentException("求负数阶段异常");
double s=1;
for(int i=1;i<=n;i++)
{
s=s*i;
return s;
}
}
public static void main(String[] args)
{
try
{
int m=Integer.parseInt(args[0]);
System.out.println(m+"!="+multi(m));
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("命令行中没有参数");
}
catch(NumberFormatException e)
{
System.out.println("应输入一个整数!");
}
catch(IllegalArgumentException e)
{
System.out.println("出现的异常是"+e.toString());
}
finally
{
System.out.println("程序运行结束");

代码错误,你总应该说一下是什么错误吧,让大家猜这可不是什么好事。
猜 的话,常见的无非就是数值范围越界了。

有什么错误提示?先发出来看看吧。

这应该是一个求N!的程序,multi函数没有返回值,我简单修改了一下:

```public class App9_4 {
public static double multi(int n) {
if (n < 0)
throw new IllegalArgumentException("求负数阶段异常");
double s = 1;
for (int i = 1; i <= n; i++) {
s = s * i;
}
return s;
}

public static void main(String[] args) {
    try {
        int m = Integer.parseInt(args[0]);
        System.out.println(m + "!=" + multi(m));
    } catch (ArrayIndexOutOfBoundsException e) {
        System.out.println("命令行中没有参数");
    } catch (NumberFormatException e) {
        System.out.println("应输入一个整数!");
    } catch (IllegalArgumentException e) {
        System.out.println("出现的异常是" + e.toString());
    } finally {
        System.out.println("程序运行结束");
    }
}

}


骚年你的return语句位置不对啊,你要让他计算阶乘起码要到for外边啊。

multi可能没有返回值 。
故加入return 0即可。

    public static double multi(int n) {
        if (n < 0)
            throw new IllegalArgumentException("求负数阶段异常");
        double s = 1;
        for (int i = 1; i <= n; i++) {
            s = s * i;
            return s;
        }
    }
    public static double multi(int n) {
        if (n < 0)
            throw new IllegalArgumentException("求负数阶段异常");
        double s = 1;
        for (int i = 1; i <= n; i++) {
            s = s * i;
            return s;
        }
        return 0; //添加了这里。
    }