我的 java 代码有什么问题? (解析错误)

What's wrong with my java code? (parsing error)

public class 1127 
{
    public static void main(String[] args)
    {
        binomial();
    }

    public static double binomial(int N, int k, double p)
    {
        if (N == 0 && k ==0) return 1.0;
        if (N < 0 || k < 0) return 0.0;
        return (1.0 - p)*binomial(N-1, k, p) + p*binomial(N-1, k-1, p);
    }
}

/Volumes/2/Learn_Algorithms/chapter one/1127.java:13: reached end of file while parsing }}
SUBNULNULNULNULNULNULNULNULNUL

^ 15 Errors

这是我第一次编写 Java 代码,我有几个问题。

  1. "reached end of file while parsing" 是什么意思?

我想我没有遗漏任何“{”或“}”

  1. 那么 SUBNULNULNUL 系列呢...?

  2. 15个错误是怎么算出来的?

名称 1127 不是 class 的有效名称。

一个class名字是一个identifier并且必须以字母开头;标识符不能以数字开头。

你必须有参数才能在 main 中调用你的函数:

binomial(a,b,c);

干杯! :)

不要以 number/integer 开头 class 名称。 class 名称应该是 Java 中的有效标识符。看这里关于identifiers的规则。