java(小练习)当读⼊的n 分别为1,2,3,4,5 时,输出的结果分别是什么
程序员文章站
2022-04-16 10:01:42
...
package com.fy.t2;
import java.io.*;
import java.sql.*;
class Test2{
public static void main(String args[]){
System.out.println("main 1");
int n; //读⼊n
ma(4);
System.out.println("main2");
}
public static void ma(int n){
try{
System.out.println("ma1");
mb(n);
System.out.println("ma2");
}catch(EOFException e){
System.out.println("Catch EOFException");
}catch(IOException e){
System.out.println("Catch IOException");
}catch(SQLException e){
System.out.println("Catch SQLException");
}catch(Exception e){
System.out.println("Catch Exception");
}finally{
System.out.println("In finally");
}
}
public static void mb(int n) throws Exception{
if (n == 1) throw new EOFException();
if (n == 2) throw new FileNotFoundException();
if (n == 3) throw new SQLException();
if (n == 4) throw new NullPointerException();
System.out.println("mb2");
}
}
当n为4时的输出结果
上一篇: Tomcat性能调优
下一篇: java_成员内部类