我正在尝试创建自己的异常,但遇到了问题...
class MyException extends Exception {
MyException (String w) { super ( w ); }
};
public class RozkladLiczby{
private int[] Array;
RozkladLiczby(int n) throws MyException {
try{
Array = new int[n+2];
}
catch(OutOfMemoryException ex){
throw new MyException ("Not enough memory" );
}
}
}
编译器说它在 catch 中找不到符号。
RozkladLiczby.java:16: error: cannot find symbol
catch(OutOfMemoryException ex){
^
symbol: class OutOfMemoryException
location: class RozkladLiczby
1 error