62,623
社区成员
发帖
与我相关
我的任务
分享public class test3
{
public void method1(int x)
{
try
{
System.out.println(" see ");
method2(x); //提示出错:Unhandled exception type Exception
System.out.println(" no see ");
}
catch (NegativeArraySizeException e)
{
System.out.println( "Checkpoint 1 ");
}
finally
{
System.out.println( "Checkpoint 2 ");
}
System.out.println( "Checkpoint 3 ");
}
public void method2(int x) throws Exception
{
if (x < 0)
{
throw new NegativeArraySizeException();
}
}
static public void main(String[] args) throws Exception
{
test3 t = new test3();
for(int i =1;i<5;i++){
t.method1(-55);
System.out.println("for "+i);
}
System.out.println( "Checkpoint 4 ");
}
}
public class test3 {
public void method1(int x) {
try {
method2(x);
} catch (NegativeArraySizeException e) {
System.out.println("Checkpoint 1 ");
} finally {
System.out.println("Checkpoint 2 ");
}
System.out.println("Checkpoint 3 ");
}
public void method2(int x) {
if (x < 0) {
throw new NegativeArraySizeException();
}
}
static public void main(String[] args) {
test3 t = new test3();
t.method1(-55);
System.out.println("Checkpoint 4 ");
}
}
public class test3 {
public void method1(int x) throws Exception {
try {
method2(x);
} catch (NegativeArraySizeException e) {
System.out.println("Checkpoint 1 ");
} finally {
System.out.println("Checkpoint 2 ");
}
System.out.println("Checkpoint 3 ");
}
public void method2(int x) throws Exception {
if (x < 0) {
throw new NegativeArraySizeException();
}
}
static public void main(String[] args) throws Exception {
test3 t = new test3();
t.method1(-55);
System.out.println("Checkpoint 4 ");
}
}