找不到符号抛出IndexOutOfBoundException

时间:2014-12-04 13:55:11

标签: java

我有以下简单类:

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编程以来已经有一段时间但我在这里看不出任何错误。

1 个答案:

答案 0 :(得分:6)

它是IndexOutOfBoundsException,而不是IndexOutOfBoundException

你错过了一个S