IndexOutOfBoundException

IndexOutOfBoundException

我有以下简单的课程:

public class Polynomial {
    private double[] c;
    public double get(int i) throws IndexOutOfBoundException { return c[i]; }
    public void set(int i, double a) throws IndexOutOfBoundException, ArithmeticException { c[i] = a; }
}


编译时出现此错误:

Polynomial.java:39: error: cannot find symbol
    public double get(int i) throws IndexOutOfBoundException { return c[i]; }
                                    ^
  symbol:   class IndexOutOfBoundException
  location: class Polynomial
Polynomial.java:42: error: cannot find symbol
    public void set(int i, double a) throws IndexOutOfBoundException, ArithmeticException { c[i] = a; }
                                            ^
  symbol:   class IndexOutOfBoundException
  location: class Polynomial
2 errors


为什么我得到cannot find symbol作为例外IndexOutOfBoundException?自上次我用Java编程以来已经有一段时间了,但是我在这里没有发现任何错误。

最佳答案

它是IndexOutOfBoundsException,而不是IndexOutOfBoundException

您缺少S

07-26 06:27