源题目是这样——
下列代码输出结果是什么—— class SuperClass
{
public void method() throws IOException
{
//statements
}
}
public class SubClass extends SuperClass
{
public void method throws ArrayIndexOutOfBoundsException,IOException
{
//statements
}
}提出问题是这个程序的扩充,形式大概那样。请教~~~
下列代码输出结果是什么—— class SuperClass
{
public void method() throws IOException
{
//statements
}
}
public class SubClass extends SuperClass
{
public void method throws ArrayIndexOutOfBoundsException,IOException
{
//statements
}
}提出问题是这个程序的扩充,形式大概那样。请教~~~
public void method() throws IOException
^
1 error你真的编译通过 了吗?我编译怎么不通过
还是用try catch finally吧
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--java.lang.RuntimeException <-注意这里
|
+--java.lang.IndexOutOfBoundsException
|
+--java.lang.ArrayIndexOutOfBoundsException
java.lang.Object
|
+--java.lang.Throwable
|
+--java.lang.Exception
|
+--java.io.IOExceptionArrayIndexOutOfBoundsException属于RuntimeException,是运行时异常,这种异常很难再编程的时候预见到所以有的RuntimeException都不必在throws语句中显示的写出也就是说throws ArrayIndexOutOfBoundsException,IOException 和throws IOException是没有区别的你明白了吗?