动手动脑练习2

11.7

今天练习异常处理

下面是代码部分:

package lianxi;
import javax.swing.*;
public class bo {

public static void main(String[] args) {
try
{


System.out.println("in main");

throw new Exception("Exception is thrown in main");

//System.exit(0);


}

catch(Exception e)

{

System.out.println(e.getMessage());

System.exit(0);

}

finally

{

System.out.println("in finally");

}
}
}

 运行结果:

 

posted @ 2020-11-07 21:42  潘福龙  阅读(48)  评论(0编辑  收藏  举报