📄 testexception2.java
字号:
import com.kettas.common.*;
import java.io.*;
import java.sql.*;
public class TestException2{
public static void main(String args[]){
int n = SystemIn.readInt();
System.out.println("main 1");
int s = ma(n);
System.out.println(s);
System.out.println("main 2");
}
static int ma(int n) {
try{
System.out.println("ma 1");
mb(n);
System.out.println("ma 2");
//return 10;
}
catch(SQLException e){
System.out.println("Catch a SQL Exception");
System.out.println( e.getMessage() );
e.printStackTrace();
//return 5;
}
catch(IOException e){
System.out.println("Catch a IO Exception");
//return 5;
}
catch(Exception e){
System.out.println("Catch an Exception");
//return 5;
}
finally{
System.out.println("In Finally");
return 3;
}
}
static void mb(int n) throws IOException,SQLException{
System.out.println("mb 1");
mc(n);
System.out.println("mb 2");
}
static void mc(int n) throws FileNotFoundException,EOFException,SQLException{
System.out.println("mc 1");
if (n == 0) throw new NullPointerException("KongZhiZhen");
if (n == 1) throw new EOFException("End Of File");
if (n == 2) throw new FileNotFoundException("File Not Found");
if (n == 3) throw new SQLException( "Database Exception" );
System.out.println("mc 2");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -