/*
* TestException.java
*
* Created on 2006年6月19日, 上午8:27
*
* To change this template, choose Tools | Template Manager
* and open the template in the editor.
*/
//package test;
/**
*
* @author vlinux
*/
public class TestException {
private void function_S1( String number ) throws S1Exception {
System.out.println("我是S1:我喜欢白菜。");
}
private void function_S2( String number ) throws Exception {
throw new Exception();
}
private void function_S3(){
System.out.println("我是S3:我喜欢踢老K屁股!");
}
private void function_S4( String number ){
System.out.println("我是S4:管你发生不发生异常,我照样运行!");
}
/** Creates a new instance of TestException */
public TestException() {
try{
this.function_S1("c");
this.function_S2("exception");
this.function_S3();
}catch(Exception s2){
System.out.println("我是Exception:S2发生异常了!");
}
this.function_S4("4");
}
public static void main(String args[]){
new TestException();
}
}
举个简单的例子