import java.io.*;
public class TryTest
{
public TryTest()
{
try {
int[] a=new int[2];
a[4]=4;
System.out.println("After handing exception return here?");
}
catch(IndexOutOfBoundsException e)
{
System.out.println("Exception msg:"+e.getMessage());
System.out.println("Exception string:"+e.toString);
e.printStackTrance();
}
finally
{
System.out.println("-------------------");
System.out.println("finally");
}
System.out.println("NO expection");
}
public static void main(String args[])
{
new TryTest();
}
}
public class TryTest
{
public TryTest()
{
try {
int[] a=new int[2];
a[4]=4;
System.out.println("After handing exception return here?");
}
catch(IndexOutOfBoundsException e)
{
System.out.println("Exception msg:"+e.getMessage());
System.out.println("Exception string:"+e.toString);
e.printStackTrance();
}
finally
{
System.out.println("-------------------");
System.out.println("finally");
}
System.out.println("NO expection");
}
public static void main(String args[])
{
new TryTest();
}
}
public class TryTest
{ public TryTest()
{
try {
int[] a=new int[2];
a[4]=4;
System.out.println("After handing exception return here?");
}
catch (IndexOutOfBoundsException e)
{
System.out.println("Exception msg:"+e.getMessage());
System.out.println("Exception string:"+e.toString());
e.printStackTrace();
}
finally
{
System.out.println("-------------------");
System.out.println("finally");
}
System.out.println("NO expection");
} public static void main(String args[])
{
new TryTest();
}
}我这边运行通过了,我发现你 catch后面的括号有问题,以及 e.toString()后面你的括号也没有~~
e.toString()