A subclass must come before its superclass in
a series of catch statements. If not,
unreachable code will be created and a
compile-time error will result.
*/
class SuperSubCatch {
public static void main(String args[]) {
try {
int a = 0;
int b = 42 / a;
} catch(Exception e) {
System.out.println("Generic Exception catch.");
}
/* This catch is never reached because
ArithmeticException is a subclass of Exception. */
catch(ArithmeticException e) { // ERROR - unreachable
System.out.println("This is never reached.");
}
}
}
class TempClass
{
public int X(int [] a) throws TempException
{
if (a.length<>23)
throw new TempException("the number of the array is "+a.length);
or
if (y<=0)
throw new TempException("Divisor is "+y);
int Y;
Y=a.length;
System.out.println("the number of the array is "+a.length);
return Y;
}
}
class TempException extends Exception
{
public TempException(String msg)
{
super(msg);
}
}
class Test
{
public static void main(String [] args)
{
int a = args.length;
System.out.println("a = " + a);
int b = 23 / a;
int c[] = { 1 };
c[23] = 99;
}
catch(TempException e)
{
System.out.println(e.getMessage());
System.out.println("异常");
e.printStackTrace();
}
}
}
帮我看下哪里有错好么
谢谢了~