1
我有以下簡單的類:找不到符號拋出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編程已經有一段時間了,但我沒有看到任何錯誤。
當編譯器抱怨找不到符號時,* always *檢查第一步是否有錯別字。複製找不到的符號,然後在你認爲你已經知道的上下文中使用「find」(例如javadocs) – 2014-12-04 13:59:40