是对继承类的认识错误:)正确的代码如下:
package execptiondl;
import execptiondl.dlexception;
public class Ninetyeight //throws dlexecption
{
public Ninetyeight( )
{
int i = 0;
String DiavArray[] = {"A","B","C","D"};
System.out.println("Hello World!");
try{
while(i<5)
{
System.out.println(DiavArray[i]);
i++;
}
}//try
//catch(ArrayIndexOutOfBoundsException e)
catch(dlexception e){
System.out.println(e.toString( ));} }
public static void main(String[] args) //throws Exception
{
Ninetyeight d = new Ninetyeight();
}
}package execptiondl;
import java.lang.Throwable.*;
public class dlexception extends ArrayIndexOutOfBoundsException
{public String toStrng( )
{
return "异常抛出 !";
}
}
package execptiondl;
import execptiondl.dlexception;
public class Ninetyeight //throws dlexecption
{
public Ninetyeight( )
{
int i = 0;
String DiavArray[] = {"A","B","C","D"};
System.out.println("Hello World!");
try{
while(i<5)
{
System.out.println(DiavArray[i]);
i++;
}
}//try
//catch(ArrayIndexOutOfBoundsException e)
catch(dlexception e){
System.out.println(e.toString( ));} }
public static void main(String[] args) //throws Exception
{
Ninetyeight d = new Ninetyeight();
}
}package execptiondl;
import java.lang.Throwable.*;
public class dlexception extends ArrayIndexOutOfBoundsException
{public String toStrng( )
{
return "异常抛出 !";
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货